尝试使用pip时出现运行时错误

时间:2016-06-21 13:44:12

标签: python-2.7 pip python-requests python-cffi

我已经设法通过做一些看似无害的事情来使我自己搞砸了。

我从我的python脚本中得到以下错误(品牌['feed'] =我正在发出请求的网址):

**C:\Python27\lib\site-packages\requests\packages\urllib3\util\ssl_.py:90: 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.

  InsecurePlatformWarning

Traceback (most recent call last):

  File "D:\Phocas\Phocas-Automation\analytics\download_feed_cats.py", line 18, in <module>

    data = requests.get(brand['feed'])

  File "C:\Python27\lib\site-packages\requests\api.py", line 69, in get

    return request('get', url, params=params, **kwargs)

  File "C:\Python27\lib\site-packages\requests\api.py", line 50, in request

    response = session.request(method=method, url=url, **kwargs)

  File "C:\Python27\lib\site-packages\requests\sessions.py", line 465, in request

    resp = self.send(prep, **send_kwargs)

  File "C:\Python27\lib\site-packages\requests\sessions.py", line 594, in send

    history = [resp for resp in gen] if allow_redirects else []

  File "C:\Python27\lib\site-packages\requests\sessions.py", line 196, in resolve_redirects

    **adapter_kwargs

  File "C:\Python27\lib\site-packages\requests\sessions.py", line 573, in send

    r = adapter.send(request, **kwargs)

  File "C:\Python27\lib\site-packages\requests\adapters.py", line 431, in send

    raise SSLError(e, request=request)

requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed**

所以我问互联网和互联网说这样做:

pip install --upgrade ndg-httpsclient

所以我这样做了,现在我继续运行RuntimeError,当我运行相同的脚本时,即使我只是尝试在shell中运行pip,我也会得到同样的错误!

Phocas_Tommy@p3303386 MINGW64 /c/Python27
$ pip


Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
  File "C:\Python27\lib\site-packages\pip\__init__.py", line 11, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "C:\Python27\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "C:\Python27\lib\site-packages\pip\download.py", line 22, in <module>
    from pip._vendor import requests, six
  File "C:\Python27\lib\site-packages\pip\_vendor\requests\__init__.py", line 53, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\contrib\pyopenssl.py", line 43, in <module>
    import OpenSSL.SSL
  File "C:\Python27\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "C:\Python27\lib\site-packages\OpenSSL\rand.py", line 12, in <module>
    from OpenSSL._util import (
  File "C:\Python27\lib\site-packages\OpenSSL\_util.py", line 9, in <module>
    binding = Binding()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 114, in __init__
    self._ensure_ffi_initialized()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 126, in _ensure_ffi_initialized
    cls._modules,
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", line 31, in load_library_for_binding
    lib = ffi.verifier.load_library()
  File "C:\Python27\lib\site-packages\cffi\verifier.py", line 96, in load_library
    self._compile_module()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", line 127, in _compile_module
    "Attempted implicit compile of a cffi module. All cffi modules should "
RuntimeError: Attempted implicit compile of a cffi module. All cffi modules should be pre-compiled at installation time.

我搜索过这个错误,似乎找不到任何有用的东西。我在Windows Server 2008 R2 Standard 64位上使用python 2.7.6

1 个答案:

答案 0 :(得分:0)

重新安装Python解决了这个问题