我正在尝试使用get_pip.py文件在我的Mac Yosemite 10.10.5上安装pip,但我遇到以下问题
Bachirs-MacBook-Pro:Downloads bachiraoun$ sudo python get-pip.py
The directory '/Users/bachiraoun/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/bachiraoun/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
/tmp/tmpOofplD/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
/tmp/tmpOofplD/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [Errno 1] _ssl.c:510: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm - skipping
Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
根据我的错误消息和urllib3我的问题是因为我的python安装版本早于2.7.9,但我的python是2.7.10,你可以看到
Bachirs-MacBook-Pro:docs bachiraoun$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0)
>>>
我验证了我的openssl已经安装好了,似乎没问题
Bachirs-MacBook-Pro:docs bachiraoun$ brew install openssl
Warning: openssl-1.0.2f already installed
不确定如何解决这个问题?
答案 0 :(得分:26)
需要安装:
pip install pyopenssl ndg-httpsclient pyasn1
链接: http://urllib3.readthedocs.org/en/latest/security.html#openssl-pyopenssl
默认情况下,我们使用标准库的ssl模块。不幸的是,PyOpenSSL解决了一些限制:
(Python 2.x)SNI支持。 (Python 2.x-3.2)禁用压缩以缓解CRIME攻击。
要使用Python OpenSSL绑定,您需要安装所需的包:
pip install pyopenssl ndg-httpsclient pyasn1
答案 1 :(得分:1)
您的文件夹权限存在问题。
的文件夹/Users/ME/Library/Caches/pip/http
或其中一个祖先不属于您打算与之交互的用户。您需要检查您尝试执行此操作的用户,并且需要确保给定用户对路径中的所有文件夹具有必要的权限。
答案 2 :(得分:1)
第一行和第二行输出表明该文件夹的权限存在问题。您可以通过执行ls -a /Users/ME/Library
并检查权限是否等于drwx------+
来查看是否需要更改权限。如果不是,您可以使用chmod更改权限来解决问题:chmod 700 /Users/ME/Library
。
然而,当第一个执行行(Bachirs-MacBook-Pro:Downloads ME$
)以ME$
为前缀时,您不应该出现此问题。您还以root身份运行get_pip.py
,因此权限不应成为障碍。当您查看第二个执行行(Bachirs-MacBook-Pro:Downloads bachiraoun$
)时,问题变得更加清晰,似乎脚本正在执行bachiraoun
而不是ME
,这可以解释为什么会出现错误有。我假设你以异常方式进入shell,因为它不应该像那样改变。你能否提供一些关于你如何进入shell的详细信息?你可以重新运行脚本吗?
如果权限不是问题,则可能就是这个问题。第四行似乎表明ssl存在问题。如果您安装了自制软件,则可以执行brew install openssl
。请注意,自制软件缺乏sudo并不能很好地发挥作用。之后再尝试运行脚本。同样,它很可能是权限错误,您应该首先尝试解决该问题。