安装Python的pip时出错

时间:2017-02-01 22:57:05

标签: python macos python-2.7 pip

要安装python软件包,必须安装pip。这里有非常明确的说明:https://packaging.python.org/installing/

但是,当尝试通过python get-pip.py安装pip时,我收到以下错误:

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

无济于事,我已尝试按照GitHub上的建议(https://github.com/pypa/pip/issues/3761)更改我的权限并禁用系统完整性保护,如此链接(http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/)所示。< / p>

另请注意,我的计算机上不存在pip

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

我正在运行OSX 10.12.2。

1 个答案:

答案 0 :(得分:2)

<强>解决方案:

在尝试了特里斯坦的&amp; Coolq B的建议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. 有效。 然而,如果一开始你没有成功,请再试一次:第一次尝试后,我遇到了超时错误。我再次尝试了它并且它有效。结果均发布:

首先尝试(超时错误):

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

第二次尝试(成功):

{{1}}