Reputation: 3336
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.
Upvotes: 6
Views: 8879
Reputation: 2990
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!
Upvotes: 8
Reputation:
Check the python version you are calling. Run "python --version". If it's not 3.7.1, that's the problem. If it returns a version beginning with "2", then try running the python3 binary instead.
Upvotes: -1