I have requests module installed and I have tested through virtual python environment this program and it works(as in prints the right answer).
import requests
payload = {'key1': 'value1', 'key2': ['value2', 'value3']}
r = requests.get('http://httpbin.org/get', params=payload)
print(r.url)
But when this program is in /public_html/wp-content/plugins
I get ImportError: No module named requests
so I figured that the problem might be because PYTHONPATH environment variable is not set properly, so I created in /public_html/wp-content/plugins/path
__init__.py
, empty py file, and added to the end of .bashrc
export PYTHONPATH=${PYTHONPATH}:/public_html/wp-content/plugins/path
, then run source ~/.bashrc
command through ssh to reset it. Python program still gives me that error, I have used this Permanently add a directory to PYTHONPATH to help me to change Pythonpath.
Am I approaching this issue wrong way, or am I missing something when trying to change PYTHONPATH, what the problem could be? Thanks for reading.
EDIT: I have fixed the problem, what I had to do is just install those modules into the file that has scripts that need to be executed, but now I have another problem, the server is executing those scripts automatically as python
, but they need to be executed as python3
, maybe you know how could this be changed? Thanks.