2015-05-13 98 views
1

昨天我試圖用pip安裝一些python軟件包,但它不起作用。pip無法與pypi服務器建立安全連接

[email protected]:~$ pip install isort -v 
Downloading/unpacking isort 
    Could not fetch URL https://pypi.python.org/simple/isort/: connection error: [Errno 0] _ssl.c:344: error:00000000:lib(0):func(0):reason(0) 
    Will skip URL https://pypi.python.org/simple/isort/ when looking for download links for isort 
    Could not fetch URL https://pypi.python.org/simple/: connection error: [Errno 0] _ssl.c:344: error:00000000:lib(0):func(0):reason(0) 
    Will skip URL https://pypi.python.org/simple/ when looking for download links for isort 
    Cannot fetch index base URL https://pypi.python.org/simple/ 
    Could not fetch URL https://pypi.python.org/simple/isort/: connection error: [Errno 0] _ssl.c:344: error:00000000:lib(0):func(0):reason(0) 
    Will skip URL https://pypi.python.org/simple/isort/ when looking for download links for isort 
    Could not find any downloads that satisfy the requirement isort 
Cleaning up... 
    Removing temporary dir /tmp/pip_build_paquete... 
No distributions at all found for isort 
Exception information: 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main 
    status = self.run(options, args) 
    File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run 
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) 
    File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1177, in prepare_files 
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade) 
    File "/usr/lib/python2.7/dist-packages/pip/index.py", line 277, in find_requirement 
    raise DistributionNotFound('No distributions at all found for %s' % req) 
DistributionNotFound: No distributions at all found for isort 

Storing debug log for failure in /tmp/tmpl86YQE 

我一直在尋找一個在互聯網上沒有成功的答案。 2012年的很多答案都表明要降級,但那個麻煩的bug從那以後就被修復了。

[email protected]:~$ pip -V 
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7) 

有些人有他們的python解釋器的問題,但它似乎很好地連接到服務器。

[email protected]:~$ python 
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import httplib 
>>> conn = httplib.HTTPSConnection("pypi.python.org") 
>>> conn.request("GET","/simple/") 
>>> res = conn.getresponse() 
>>> print res.status, res.reason 
200 OK 

作爲附加信息,我在幾個星期前做了一次全新的初級安裝。這發生在所有軟件包中。我通過apt安裝了所有東西,所以這似乎有任何想法?

更新 繼@andersson的建議後,我嘗試安裝pip的最新版本。然後這掏出

[email protected]:~$ sudo python3 Downloads/get-pip.py -v 
The directory '/home/paquete/.cache/pip/log' or its parent directory is not owned by the current user and the debug log 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 '/home/paquete/.cache/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. 
Starting new HTTPS connection (1): pypi.python.org 
There was an error checking the latest version of pip 
Traceback (most recent call last): 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py", line 253, in ssl_wrap_socket 
    context.load_verify_locations(ca_certs) 
ssl.SSLError: unknown error (_ssl.c:2734) 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/adapters.py", line 370, in send 
    timeout=timeout 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 544, in urlopen 
    body=body, headers=headers) 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 341, in _make_request 
    self._validate_conn(conn) 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 762, in _validate_conn 
    conn.connect() 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/connection.py", line 238, in connect 
    ssl_version=resolved_ssl_version) 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py", line 255, in ssl_wrap_socket 
    raise SSLError(e) 
pip._vendor.requests.packages.urllib3.exceptions.SSLError: unknown error (_ssl.c:2734) 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/tmp/tmp8w985p0e/pip.zip/pip/utils/outdated.py", line 126, in pip_version_check 
    headers={"Accept": "application/json"}, 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/sessions.py", line 476, in get 
    return self.request('GET', url, **kwargs) 
    File "/tmp/tmp8w985p0e/pip.zip/pip/download.py", line 367, in request 
    return super(PipSession, self).request(method, url, *args, **kwargs) 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/sessions.py", line 464, in request 
    resp = self.send(prep, **send_kwargs) 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/sessions.py", line 576, in send 
    r = adapter.send(request, **kwargs) 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/cachecontrol/adapter.py", line 46, in send 
    resp = super(CacheControlAdapter, self).send(request, **kw) 
    File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/adapters.py", line 431, in send 
    raise SSLError(e, request=request) 
pip._vendor.requests.exceptions.SSLError: unknown error (_ssl.c:2734) 

這似乎是一個通用的問題。

+0

要添加更多的神祕感,舊的virtualenv點工作得很好。 – elpaquete

回答

0

通過迅速解決:

sudo update-ca-certificates

0

我也有一些問題與默認(1.5.4)pip版本。你能否成功更新點到最新(6.1.1)版本,或者你已經嘗試和安裝兩個點的版本都失敗了?

+0

我有點高興,它不只是我。按照https://pip.pypa.io/en/latest/installing.html中的步驟運行get-pip.py。 /tmp/tmpRJjSJP/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79:InsecurePlatformWarning:一個真正的SSLContext對象不可用。這可以防止urllib3正確配置SSL,並可能導致某些SSL連接失敗。有關更多信息,請參閱https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning。 我會愛上這個。 – elpaquete

+0

我在問題中添加了更多信息。 – elpaquete

2

我的問題是稍有不同。看起來https://pypi.python.org/simple/證書在2016年6月被續訂,所以如果您的操作系統的日期早於該日期,則無論是否安裝了正確的CA證書,您在驗證證書時都會遇到問題。

相關問題