Tonight I am trying to get the package called \"requests\" installed and have begun fumbling around with the terminal and do not have very much intuition when it comes to th
You are trying to install the package in '/Library/Python/2.7/site-packages/requests' but it requires root permissions to do so. This should do the trick:
$ sudo pip install requests
From what I can tell you have three versions of Python on your system.
/Library/Frameworks/Python.framework/Versions/2.7/
/Library/Python/2.7/site-packages
pip is installed against the Python 2.7 version you downloaded (the one you see in your Applications folder), unfortunately the default Python for your shell is the one that's bundled with OSX, and there is no pip installed there.
IDLE is also bundled with the Python that you downloaded, which is why it keeps telling you that pip is installed, but it doesn't work from the shell.
Since you are probably using the Python downloaded from python.org as your "primary" Python (after all, its the one with IDLE that you are using), you need to set your shell environment to point to this Python as default.
The easiest way to do that is to add a variable in .bashrc
that creates an alias python
and points it to the right binary. To do that, add this line to /Users/yourusername/.bashrc
- files with .
are hidden by default, so you'll have to write the entire file name in the command line to open it. Add the following line:
alias python=/Library/Python/2.7/python
Save the file and then close all terminal windows and open it again. Now type pip
and it should work correctly, and then you can proceed to installing requests.
For future reference, try to stick with one version of Python. I personally ignore the bundled version and use the one from brew, but you can stick to the Python downloaded from python.org.
site.py is a standard module that is run by python by default. It allows tweaking sys.path and running some code before your code starts running. It should live in the standard library and can hardly be somehow absent. However, you can disable automatic importing of the module by passing -S switch to python.
Anyway, you should somehow inspect why the module can not be imported. Try to examine sys.path list.
I met the same question, and error info is:
ModuleNotFoundError: No module named 'xxx'
and finally solved by
brew install python3
brew link python3
sudo python3 -m pip install xxx
// or `sudo python3 -m pip install -r requirements.txt`
I fixed mine with:
brew reinstall python
It fixed all my broken paths. I think I broke it with a broken brew package that had a wrong python version dependancy or something like that.
sudo easy_install pip
sudo pip install requests