writing some python in OS X, and it\'s saying several packages I installed with pip \"ImportError: no module named requests\"
When running pip install requests
Run in command prompt.
pip list
Check what version you have installed on your system if you have an old version.
Try to uninstall the package...
pip uninstall requests
Try after to install it:
pip install requests
You can also test if pip does not do the job.
easy_install requests
i had the same issue(also in MAC OS) and solved it by instead running the python script with python3: python3 script.py
in my case i was also using pip3 and not pip.
I suffered from this problem and finally found the solution.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: django in /usr/lib/python3/dist-packages (2.2.12)
use 'sudo' to crossoff user installation issue;
and pip install --target=/usr/local/python3.7/site-packages --upgrade {module_name}
someone mentioned this and worked for me.
If you are using a Mac, it could be that you installed the modules with pip (meaning python2, but you execute your code with python3 which does not have the modules you installed for python2).
Mac has python version 2 set as default and usually does not come with pip preinstalled or is linked with version 2. I recommend leaving it that way. Use version 3 for your personal use cases and leave your Mac with version 2 as default. As you have to install python3 yourself, means you might also want to check/install pip3.
Check if you have python 3 installed:
python3 --version
Check if you have pip3 installed (usually included by default since python 3.4):
pip3 --version
Check what packages you have installed with pip3:
pip3 list
If you use an editor tool, make sure to set it to use python3 when running your file.
Example for VS Code: Set VS Code to use Python3 on the bottom right corner, which you should see when having a .py file open:
And now if you want to import any modules into python, make sure to install them with pip3:
pip3 install package_name
If you run into permission issue, you might consider to run the command with sudo rights:
sudo pip3 install package_name