Pip:无法获取pypi的URL并确认ssl证书

时间:2017-03-23 14:41:24

标签: windows python-3.x pip easy-install

我最近刚刚安装了运行pip(9.0.1)的python(3.6.1),并且在我尝试安装软件包时出现以下错误:

pip install cx_Oracle

Collecting cx_Oracle
  Could not fetch URL https://pypi.python.org/simple/cx-oracle/: There was a pro
blem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificat
e verify failed (_ssl.c:749) - skipping
  Could not find a version that satisfies the requirement cx_Oracle (from versio
ns: )
No matching distribution found for cx_Oracle

由于证书出现问题我尝试这样做:

pip install --trusted-host pypi.python.org pytest-xdist

Collecting pytest-xdist
  Downloading pytest-xdist-1.15.0.tar.gz (87kB)
    100% |████████████████████████████████| 92kB 1.8MB/s
    Complete output from command python setup.py egg_info:
    Download error on https://pypi.python.org/simple/setuptools_scm/: [SSL: CERT
IFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages m
ay not be found!
    Download error on https://pypi.python.org/simple/setuptools-scm/: [SSL: CERT
IFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages m
ay not be found!
    Couldn't find index page for 'setuptools_scm' (maybe misspelled?)
    Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_
FAILED] certificate verify failed (_ssl.c:749) -- Some packages may not be found
!
    No local packages or working download links found for setuptools_scm
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\ALEX~1.CAU\AppData\Local\Temp\pip-build-7vo4jump\pytest-xdi
st\setup.py", line 37, in <module>
        'Programming Language :: Python :: 3',
      File "c:\users\alex.cauthen\appdata\local\programs\python\python36\lib\dis
tutils\core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "c:\users\alex.cauthen\appdata\local\programs\python\python36\lib\sit
e-packages\setuptools\dist.py", line 315, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "c:\users\alex.cauthen\appdata\local\programs\python\python36\lib\sit
e-packages\setuptools\dist.py", line 361, in fetch_build_eggs
        replace_conflicting=True,
      File "c:\users\alex.cauthen\appdata\local\programs\python\python36\lib\sit
e-packages\pkg_resources\__init__.py", line 850, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "c:\users\alex.cauthen\appdata\local\programs\python\python36\lib\sit
e-packages\pkg_resources\__init__.py", line 1122, in best_match
        return self.obtain(req, installer)
      File "c:\users\alex.cauthen\appdata\local\programs\python\python36\lib\sit
e-packages\pkg_resources\__init__.py", line 1134, in obtain
        return installer(requirement)
      File "c:\users\alex.cauthen\appdata\local\programs\python\python36\lib\sit
e-packages\setuptools\dist.py", line 429, in fetch_build_egg
        return cmd.easy_install(req)
      File "c:\users\alex.cauthen\appdata\local\programs\python\python36\lib\sit
e-packages\setuptools\command\easy_install.py", line 659, in easy_install
        raise DistutilsError(msg)
    distutils.errors.DistutilsError: Could not find suitable distribution for Re
quirement.parse('setuptools_scm')

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\ALEX~1.C
AU\AppData\Local\Temp\pip-build-7vo4jump\pytest-xdist\

收到egg_info错误后,我尝试了以下操作:

easy_install -U setuptools

Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Download error on https://pypi.python.org/simple/setuptools/: [SSL: CERTIFICATE_
VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages may not b
e found!
Couldn't retrieve index page for 'setuptools'
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAIL
ED] certificate verify failed (_ssl.c:749) -- Some packages may not be found!
Best match: setuptools 28.8.0
Adding setuptools 28.8.0 to easy-install.pth file
Installing easy_install-script.py script to c:\users\alex.cauthen\appdata\local\
programs\python\python36\Scripts
Installing easy_install.exe script to c:\users\alex.cauthen\appdata\local\progra
ms\python\python36\Scripts
error: [WinError 5] Access is denied: 'c:\\users\\alex.cauthen\\appdata\\local\\
programs\\python\\python36\\Scripts\\easy_install.exe'

类似stackoverflow问题的许多答案都建议更改代理设置。我不是在代理背后工作,但我在VPN背后工作。在安装软件包时,我遇到了与NodeJS / react / npm非常类似的问题,所有建议都是为了更改代理设置。我最终通过删除存储代理设置的文件来解决问题。

我无法找到为python / pip提供相同功能的文件,并且想知道是否有人知道它在Windows 7上的位置?我也很想听听关于如何解决这个非常令人沮丧的问题的其他建议!!

亚历

2 个答案:

答案 0 :(得分:4)

我的解决方案是首先执行pip install --trusted-host pypi.python.org setuptools_scm,然后再安装pytest-xdist

除了--trusted-host pypi.python.org之外,pytest-xdist选项对我的所有要求都有效,正如您所做的那样。提示是这个特殊包裹抱怨

Couldn't find index page for 'setuptools_scm' (maybe misspelled?)

对于您的要求并不是一个完整的答案,但您的输出与我刚刚处理的内容相似,所以这些是我的笔记。

答案 1 :(得分:0)

在使用python2.7的Mac上,我有类似的pip安装错误抱怨&#34;确认ssl证书&#34;时出现问题。对于不同的包装,但对我来说解决方案可能对其他人有用。这是在我家人用的旧Mac上,我没有及时更新。一旦我更新了自制软件,升级了我们已安装的brew软件包,并使用brew来重新链接python2,问题就解决了。

brew update
brew upgrade
brew install python2
brew link --overwrite python@2