0

I am using Laradock and want to be able to run a python script from my laravel app using Symfony Process. From inside the root on my container I can run "python3 script_name.py arg1" and it runs just fine. pip list shows all modules needed. When I run it from inside Laravel, it tells me:

"import pymysql ImportError: No module named 'pymysql'"

I have used a non-docker Laravel app to do this just fine, using:

  $script = storage_path().'/app/script.py';
            $process = new Process('python3 '. $script." ".session('division'));

What am I missing?

4

1 回答 1

0

在 *nix 上,确保为所有用户正确配置了 PYTHONPATH,或者尝试设置 python3 的完整路径。

如何检查

起初你的 php 用户

php -r "print shell_exec( 'whoami' );" // somebody

运行时

su somebody python3 script_name.py arg1
于 2018-05-27T17:59:15.520 回答