pip install - Connection reset by peer

13,825

Solution 1

It turns out the mirror I was using somehow is not accessible from the network. The way I got around with it is installing it via OS directly using:

$ apt-get install python-lxml

then copy it to my virtual env:

$ cp -r /usr/lib/python2.7/dist-packages/lxml* /home/dummyuser/work/virt-dev-env/local/lib/python2.7/site-packages/

I then have it in my virtual env:

$ pip freeze
........
lxml==2.3.2
........

Solution 2

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

Solution 3

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

Disable ipv6 and try again.

Share:
13,825

Related videos on Youtube

Shengjie
Author by

Shengjie

Enthusiastic software engineer, a big fan of open source community development, big data, cloud technologies etc...

Updated on July 07, 2022

Comments

  • Shengjie
    Shengjie 6 months

    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?

    • Denis
      Denis about 10 years
      You should try with you OS package manager like apt-get install python-lxml
  • Shengjie
    Shengjie about 10 years
    yeah, now even just try to download it from pypi.python.org/simple, I hit network error. I guess something wrong with the mirror itself.
  • lunaryorn
    lunaryorn about 10 years
    @Shengjie If all PyPI mirrors fail it's more likely a problem on your end of the network.
  • R Claven
    R Claven over 5 years
    I am getting lots of "Could not find a version that satisfies the requirement XX"
  • linqu
    linqu about 5 years
    how can i do that?
  • Lauro Oliveira
    Lauro Oliveira about 5 years
    Search how to disable ipv6 in your Operational System.

Related