Sunday, 3 November 2019

Python 'No module named ...' when script is executed by php with shell_exec()

I wrote a python script that import a specific module that I have installed with pip.

When I run this script on terminal like python test.py everything work fine and when I run help("modules") I can see my module in the list (so he's well installed)

Problem is that I try to run this script with an php script using shell_exec("python test.py") but then I get the error that python don't know this module:

ImportError: No module named ...

Do you have any idea what my mistake is or how i can resolve this problem ?


> Edit 1 :

So I became apache user like @LucasMeine told me and first I see that the python version used was not the right one. So I created an alias to the good one and then I checked with the apache user and the right python version that the module exist using help("modules") in the terminal. The module was in the given list so I don't understand why in my apache error logs I get the message:

ImportError: No module named ...



from Python 'No module named ...' when script is executed by php with shell_exec()

No comments:

Post a Comment