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?

caro
  • 863
  • 3
  • 15
  • 36

1 Answers1

0

On *nix make sure that PYTHONPATH is configured correctly for all users or try to set full path to python3.

How to check

At first your php user

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

When run

su somebody python3 script_name.py arg1
Alex Komp
  • 21
  • 2