gpt4 book ai didi

python - Laravel - Python 脚本执行

转载 作者:太空狗 更新时间:2023-10-29 21:11:34 25 4
gpt4 key购买 nike

我必须执行一个将大量数据提取到数据库的 Python 脚本。当我使用命令 php artisan serve 运行项目时它工作正常,但在调用下面给出的公共(public)文件夹 URL 后抛出错误

localhost/project/public

错误:

The command "python /opt/lampp/htdocs/laravel/projectname/beta/projectname/public/python/pubmed_abstract/pubmed_engine.py '{"term":"cancer"}'" failed.

Exit Code: 1(General error) Working directory: /opt/lampp/htdocs/laravel/infocytosis/beta/infocytosis/public Output:

================ Error Output: ================

Traceback (most recent call last): File "/opt/lampp/htdocs/laravel/projectname/beta/projectname/public/python/pubmed_abstract/pubmed_engine.py", line 5, in from Bio import Entrez ImportError: No module named Bio

我使用的代码:

   $python_path=public_path().'/python/doom_abstract/doom_engine.py';

$variables='{"term":"'.addslashes($request->term).'"}';

$process = new Process("python $python_path '$variables'");
$process->run();

return redirect()->back()->withMessage('Filter saved successfully');

最佳答案

你可以试试下面的

$python_path=public_path('python/doom_abstract/doom_engine.py');

关于python - Laravel - Python 脚本执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55020489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com