0
votes

pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

After running sudo pip install -r requirements.txt

Exception:

Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)

File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 377, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/init.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/share'

Any idea why or where I can learn to read the stacktrace.

1
Looks like you don't have sufficient permissions. - Charles D Pantoga
If I were you, I would install homebrew and install python from homebrew. This way you don't upgrade/remove/change any pip packages that the system python installation requires. Homebrew will install python in /usr/local/ and you can chown /usr/local/ so that you own its contents. Then add the bin directory to your path environment variable. - Charles D Pantoga

1 Answers

0
votes

Whenever this happens and I see

OSError: [Errno 1] Operation not permitted

then it means you don't have permission. It's a little strange since you ran it via sudo. Anyway, I would use a virtual environment instead of installing the packages globally.

To create a virtual env:

virtualenv -p /usr/bin/python2.7 venv

From inside of the environment you can install your packages, so to use the virtualenv, just do:

source ./venv/bin/activate

then pip install

pip install -r requirements.txt

When you're done using the virtualenv, you can get out of it like this

deactivate

More info about virtualenv here