I'm trying to execute a simple PY file and I'm getting the following error:
Traceback (most recent call last):
File "docker_pull.py", line 8, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Looking at Python install folder I found requests module under: C:\Program Files (x86)\Python 3.7.1\Lib\site-packages\pip\_vendor\requests. How can I force Python to use the module already installed ?
P.S: I don't have internet connection in this machine.
This is a very typical issue, so I will leave this here for future reference.
If I have a project called: my_project
.
└── my_project
├── first_folder
├── second_folder
└── third_folder
What you want to do is one of these two things:
cd ~/my_project && export PYTHONPATH=$(pwd)
change dir to root dir, and export that dir to PYTHONPATH, so when Python runs it looks in the PYTHONPATH.
cd ~/my_project && export PATH=$PATH:$(pwd)
Same as above!
This needed to live somewhere since it took me a while to figure out. So for anyone in the future who needs help with this!
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