0

I am on Ubuntu16, python3.6 is installed through anaconda distribution.

I have successfully installed MySQLdb module and it works fine when called (say) from the terminal. However, when I try to execute the same python script from PHP (version 7) using

$tmp = exec("python script_name.py", $input_parameters );

I get the following error message

ImportError: No module named MySQLdb

Any ideas why this might happen? Many thanks in advance.

3
  • Please check whether you are using the right python installation. Ubuntu comes with its own. Commented Mar 26, 2018 at 18:22
  • You can check with system("which python"); Commented Mar 26, 2018 at 18:29
  • @rollstuhlfahrer, thanks for the reply! the default version is correct (it's 3.6), however since $PYTHONPATH was empty ( anaconda is added to path, so python comes from there) PHP was confusing the version of Python . Anyways, after more googling I found this question stackoverflow.com/questions/6051693/… (and your comment is also in that direction) , which resolved my problem. One needs to specify the full path of python in exec command, that's it. Commented Mar 26, 2018 at 18:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.