When i run a python script in terminal it works just fine. I then proceed to run the exact same script via PHP's shell_exec from localhost.
shell_exec("python /Applications/MAMP/htdocs/pharm/Webmaps.py")
The error it gives is:
Traceback (most recent call last): File "/Applications/MAMP/htdocs/pharm/Webmaps.py", line 1, in import folium ImportError: No module named folium
It doesn't recognize the modules that are installed. Needless to say that it works just fine from windows on localhost.
If you have multiple versions of Python on your machine, this may not work. Essentially what I think is happening is that the version of Python that is being called when you use shell_exec
is different from the one that you know folium
is installed in. Try creating a file like below:
# test.py
import sys
print(sys.version_info)
and use shell_exec("python /path/to/test.py")
. Then try python /path/to/test.py
. I expect that it will be different. Even if it is not different, it still could mean that you have two or more Python installations that are the exact same versions (unlikely, but possible). You can run the following to check that. Try both shell_exec("which python")
and which python
. I'd venture a guess that that should give you enough information to solve this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With