Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install - Connection reset by peer

When I try to install lxml using pip I had the exception "Connection reset by peer":

Downloading/unpacking lxml
  Downloading lxml-3.0.1.tar.gz (3.2Mb): 643Kb downloaded
Exception:
Traceback (most recent call last):
  File "/home/dummyuser/work/virt-dev-env/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 104, in main
    status = self.run(options, args)
  File "/home/dummyuser/work/virt-dev-env/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/install.py", line 245, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/home/dummyuser/work/virt-dev-env/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 985, in prepare_files
    self.unpack_url(url, location, self.is_download)
  File "/home/dummyuser/work/virt-dev-env/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 1109, in unpack_url
    retval = unpack_http_url(link, location, self.download_cache, self.download_dir)
  File "/home/dummyuser/work/virt-dev-env/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/download.py", line 451, in unpack_http_url
    download_hash = _download_url(resp, link, temp_location)
  File "/home/dummyuser/work/virt-dev-env/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/download.py", line 368, in _download_url
    chunk = resp.read(4096)
  File "/usr/lib/python2.7/socket.py", line 380, in read
    data = self._sock.recv(left)
  File "/usr/lib/python2.7/httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "/usr/lib/python2.7/socket.py", line 380, in read
    data = self._sock.recv(left)
error: [Errno 104] Connection reset by peer

This only happened when installing lxml, other modules got installed with pip no problems. Anybody had the same problem?

like image 785
Shengjie Avatar asked Dec 14 '12 11:12

Shengjie


Video Answer


2 Answers

Try to choose another PyPI mirror, either directly:

pip install -i http://e.pypi.python.org/simple lxml

Or by letting pip find the best mirror:

pip install --use-mirrors lxml
like image 117
lunaryorn Avatar answered Nov 11 '22 10:11

lunaryorn


In my case, was an ipv6 issue. Some mirrors still don't have full ipv6 access.

Disable ipv6 and try again.

like image 34
Lauro Oliveira Avatar answered Nov 11 '22 12:11

Lauro Oliveira