sully_r
sully_r

Reputation: 131

Error Installing pip for Python

In order to install python packages, you must have pip installed. Very clear instructions are found here: https://packaging.python.org/installing/

However, when attempting to install pip via python get-pip.py I receive the following error:

OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'

To no avail, I've tried to follow the advice on GitHub (https://github.com/pypa/pip/issues/3761) to alter my permissions and to disable System Integrity Protection as found at this link (http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/).

Also, note that pip does not exist on my machine:

Myname-MBP:python myname$ pip
-bash: pip: command not found

I'm running OSX 10.12.2.

Upvotes: 1

Views: 5725

Answers (1)

sully_r
sully_r

Reputation: 131

Solution:

After trying Tristan's & Coolq B's suggestion sudo python get-pip.py it worked. However, if at first you don't succeed, try again: after the first try, I experienced a timeout error. I tried it again and it worked. Both results posted:

First try (timeout error):

Myname-MBP:python myname$ sudo python get-pip.py
Password:
The directory '/Users/myname/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    The directory '/Users/myname/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    Collecting pip
      Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
        19% |██████▎                         | 245kB 11kB/s eta 0:01:32Exception:
    Traceback (most recent call last):
      File "/tmp/tmpq4Sjum/pip.zip/pip/basecommand.py", line 215, in main
        status = self.run(options, args)
      File "/tmp/tmpq4Sjum/pip.zip/pip/commands/install.py", line 324, in run
        requirement_set.prepare_files(finder)
      File "/tmp/tmpq4Sjum/pip.zip/pip/req/req_set.py", line 380, in prepare_files
        ignore_dependencies=self.ignore_dependencies))
      File "/tmp/tmpq4Sjum/pip.zip/pip/req/req_set.py", line 620, in _prepare_file
        session=self.session, hashes=hashes)
      File "/tmp/tmpq4Sjum/pip.zip/pip/download.py", line 821, in unpack_url
        hashes=hashes
      File "/tmp/tmpq4Sjum/pip.zip/pip/download.py", line 659, in unpack_http_url
        hashes)
      File "/tmp/tmpq4Sjum/pip.zip/pip/download.py", line 882, in _download_http_url
        _download_url(resp, link, content_file, hashes)
      File "/tmp/tmpq4Sjum/pip.zip/pip/download.py", line 603, in _download_url
        hashes.check_against_chunks(downloaded_chunks)
      File "/tmp/tmpq4Sjum/pip.zip/pip/utils/hashes.py", line 46, in check_against_chunks
        for chunk in chunks:
      File "/tmp/tmpq4Sjum/pip.zip/pip/download.py", line 571, in written_chunks
        for chunk in chunks:
      File "/tmp/tmpq4Sjum/pip.zip/pip/utils/ui.py", line 139, in iter
        for x in it:
      File "/tmp/tmpq4Sjum/pip.zip/pip/download.py", line 560, in resp_read
        decode_content=False):
      File "/tmp/tmpq4Sjum/pip.zip/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream
        data = self.read(amt=amt, decode_content=decode_content)
      File "/tmp/tmpq4Sjum/pip.zip/pip/_vendor/requests/packages/urllib3/response.py", line 324, in read
        flush_decoder = True
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in __exit__
        self.gen.throw(type, value, traceback)
      File "/tmp/tmpq4Sjum/pip.zip/pip/_vendor/requests/packages/urllib3/response.py", line 246, in _error_catcher
        raise ReadTimeoutError(self._pool, None, 'Read timed out.')
    ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.

Second Try (success):

MyName-MBP:python myname$ sudo python get-pip.py
Password:
The directory '/Users/myname/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/myname/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 143kB/s 
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 72kB/s 
Installing collected packages: pip, wheel
Successfully installed pip-9.0.1 wheel-0.29.0

Upvotes: 2

Related Questions