When I run my python script using python3, I get the following error:
Traceback (most recent call last): File "rea_scrape.py", line 2, in import requests ModuleNotFoundError: No module named 'requests'
When I run pip3 install requests
it's apparent that requests has been installed.
Requirement already satisfied: requests in /Library/Python/2.7/site-packages (2.18.4) Requirement already satisfied: certifi>=2017.4.17 in /Library/Python/2.7/site-packages (from requests) (2018.4.16) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Python/2.7/site-packages (from requests) (3.0.4) Requirement already satisfied: idna<2.7,>=2.5 in /Library/Python/2.7/site-packages (from requests) (2.6) Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Library/Python/2.7/site-packages (from requests) (1.22)
However, closer inspection of the messages seem to indicate that pip3 is installing packages for Python2.7, which is not my intention.
The result is that nothing I install using the pip3
command can be imported into a script run by python3
.
How do I fix this?
FYI I'm using MacOS High Sierra.