pip install - Connection reset by peer - python

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?

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

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
........

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

Related

I don't know what is happening when is tried to upgrade pip fro 20.2.2 to 20.2.3 is showing errors

C:\Users\sulav>python get-pip.py
python: can't open file 'get-pip.py': [Errno 2] No such file or directory
C:\Users\sulav>python -m pip install -U pip
Collecting pip
Using cached pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.2
Uninstalling pip-20.2.2:
Successfully uninstalled pip-20.2.2
Rolling back uninstall of pip
Moving to c:\users\sulav\appdata\roaming\python\python37\scripts\pip.exe
from C:\Users\sulav\AppData\Local\Temp\pip-uninstall-plw0b_z7\pip.exe
Moving to c:\users\sulav\appdata\roaming\python\python37\scripts\pip3.7.exe
from C:\Users\sulav\AppData\Local\Temp\pip-uninstall-plw0b_z7\pip3.7.exe
Moving to c:\users\sulav\appdata\roaming\python\python37\scripts\pip3.exe
from C:\Users\sulav\AppData\Local\Temp\pip-uninstall-plw0b_z7\pip3.exe
Moving to c:\users\sulav\appdata\roaming\python\python37\site-packages\pip-20.2.2.dist-info\
from c:\users\sulav\appdata\roaming\python\python37\site-packages\~ip-20.2.2.dist-info
Moving to c:\users\sulav\appdata\roaming\python\python37\site-packages\pip\
from c:\users\sulav\appdata\roaming\python\python37\site-packages\~ip
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_internal\cli\base_command.py", line 216, in _main
status = self.run(options, args)
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
return func(self, options, args)
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_internal\commands\install.py", line 421, in run
pycompile=options.compile,
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_internal\req\__init__.py", line 90, in install_given_reqs
pycompile=pycompile,
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_internal\req\req_install.py", line 821, in install
requested=self.user_supplied,
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_internal\operations\install\wheel.py", line 860, in install_wheel
requested=requested,
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_internal\operations\install\wheel.py", line 762, in _install_wheel
generated_console_scripts = maker.make_multiple(scripts_to_generate)
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 418, in make_multiple
filenames.extend(self.make(specification, options))
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_internal\operations\install\wheel.py", line 498, in make
return super(PipScriptMaker, self).make(specification, options)
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 407, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 307, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 242, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\sulav\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py", line 386, in _get_launcher
raise ValueError(msg)
ValueError: Unable to find resource t64.exe in package pip._vendor.distlib
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
You should consider upgrading via the 'C:\Users\sulav\AppData\Local\Programs\Python\Python37\python.exe -m pip install --upgrade pip' command.
You need to download get-pip.py and make sure that you are in that directory when you are trying to install it. For instance i see that the dirctory you are in is C:\Users\sulav> make sure that it is downloaded to this directory.

Raspberry python3.4 pip error unknown encoding cp437

Yesterday I was testing some python code in my raspberry pi 3 (raspbian jessie), it required the package pytz, so I did:
sudo python3 -m pip install pytz
And then this happens:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 290, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python3/dist-packages/pip/req.py", line 1198, in prepare_files
do_download,
File "/usr/lib/python3/dist-packages/pip/req.py", line 1376, in unpack_url
self.session,
File "/usr/lib/python3/dist-packages/pip/download.py", line 582, in unpack_http_url
unpack_file(temp_location, location, content_type, link)
File "/usr/lib/python3/dist-packages/pip/util.py", line 640, in unpack_file
unzip_file(filename, location, flatten=not filename.endswith(('.pybundle', '.whl')))
File "/usr/lib/python3/dist-packages/pip/util.py", line 510, in unzip_file
zip = zipfile.ZipFile(zipfp)
File "/usr/lib/python3.4/zipfile.py", line 937, in __init__
self._RealGetContents()
File "/usr/lib/python3.4/zipfile.py", line 1016, in _RealGetContents
filename = filename.decode('cp437')
LookupError: unknown encoding: cp437
It's not only with pytz, I tried to update/upgrade/reinstall pip with:
sudo python3 -m pip install -U pip
And the same error happens
Any idea about how to solve this problem?
I was searching and trying to solve it yesterday
and everything I can do right now is format the SD card.
My Pip version is 1.5.6 but I can't update it, even downloading the code and running setup.py, same problem.
I tried everything I could, and in my case I will recommend:
Copy all your important codes, changes, documents...
Format the SD and start all over again
I've been having short blackouts lately, that corrupted the SD card.

virtualenv installation SSLError: The read operation timed out

I am trying to deploy python flask application using apache2 and mod-wsgi.
I am following this link.
While installing mog-wsgi using the command sudo apt-get install libapache2-mod-wsgi ,I see these lines at the end
apache2_invoke: Enable module wsgi
Action 'configtest' failed.
The Apache error log may have more information.
apache2_reload: Your configuration is broken. Not restarting Apache 2
Is this a smooth installation?
Also, in step 1 of the link when I tried to create a virtual environment using the command
sudo virtualenv venv
This gives me error sudo: virtualenv: command not found
So, I tried to install virtualenv using sudo pip install virtualenv, I am getting this huge error in red(exception).
Downloading/unpacking virtualenv
Downloading virtualenv-15.0.1-py2.py3-none-any.whl (1.8MB): 733kB downloaded
Cleaning up...
Exception:
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 1198, in prepare_files
do_download,
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1376, in unpack_url
self.session,
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 572, in unpack_http_url
download_hash = _download_url(resp, link, temp_location)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 433, in _download_url
for chunk in resp_read(4096):
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 421, in resp_read
chunk_size, decode_content=False):
File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/response.py", line 225, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/response.py", line 174, in read
data = self._fp.read(amt)
File "/usr/lib/python2.7/httplib.py", line 573, in read
s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
File "/usr/lib/python2.7/ssl.py", line 341, in recv
return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read
return self._sslobj.read(len)
SSLError: The read operation timed out
Storing debug log for failure in /home/myname/.pip/pip.log
What could be the problem?
Please use apt-get install virtualenv or apt-get install python-virtualenv (depending on your OS version) instead of polluting the system with packages installed by sudo pip install.

'error: Error -5 while decompressing data: incomplete or truncated stream' when installing pip package

I'm having the following error when running pip install Pillow==2.9.0 in a virtualenv: error: Error -5 while decompressing data: incomplete or truncated stream
Other packages install/uninstall fine, it just seems to affects Pillow 2.9.0. It doesn't seem to matter what virtualenv I'm in (or not).
Downloading a source tarball and installing from that worked, but since this is on a build server that's not an ideal workaround as I want to rely on pip install -r requirements.txt
Versions:
pip --version: pip 7.1.0 from /usr/local/lib/python2.7/site-packages (python 2.7)
python --version: Python 2.7.10
The full traceback is:
Collecting Pillow==2.9.0
/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/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
Exception:
Traceback (most recent call last):
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/commands/install.py", line 282, in run
requirement_set.prepare_files(finder)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/req/req_set.py", line 334, in prepare_files
functools.partial(self._prepare_file, finder))
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/req/req_set.py", line 321, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/req/req_set.py", line 491, in _prepare_file
session=self.session)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/download.py", line 825, in unpack_url
session,
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/download.py", line 673, in unpack_http_url
from_path, content_type = _download_http_url(link, session, temp_dir)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/download.py", line 857, in _download_http_url
stream=True,
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/download.py", line 373, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/adapter.py", line 36, in send
cached_response = self.controller.cached_request(request)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.py", line 102, in cached_request
resp = self.serializer.loads(request, self.cache.get(cache_url))
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/serialize.py", line 108, in loads
return getattr(self, "_loads_v{0}".format(ver))(request, data)
File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/serialize.py", line 164, in _loads_v2
cached = json.loads(zlib.decompress(data).decode("utf8"))
error: Error -5 while decompressing data: incomplete or truncated stream
Turns out that there was a corrupt entry in pip's local cache (located in my case, and by default I believe, in ~/.cache/pip).
I tested that by trying pip install --no-cache-dir Pillow==2.9.0 and lo and behold, it worked.
To confirm it was the cache, I ran:
pip uninstall Pillow
rm -rf ~/.cache/pip/*
pip install Pillow==2.9.0
which succeeded where it had failed before.
I don't know how there came to be a problem with the cache, but my guess is that pip got interrupted mid-download causing the cached data for Pillow to be corrupted
I found my issue to be with memory, of the disk.
Running df showed I had used 92% memory. After deleting and cleaning the hard drive (using Disk Usage Analyzer) I was able to successfully decompress data
for anyone having similar situation as mine. It's run out of space during installation --> cache still there but corrupted.
so ?
remove this folder ~/.cache/pip and pip works again.

What is the error I am facing when I am installing Django via PIP in a virtualenv?

On my OSX 10.10.2, in a virtualenv, I tried to install Django via pip using the command:
pip install django
And this the responds I got:
Collecting django
Downloading Django-1.7.7-py2.py3-none-any.whl (7.4MB)
100% |################################| 7.4MB 58kB/s
Installing collected packages: django
Exception:
Traceback (most recent call last):
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/commands/install.py", line 347, in run
root=options.root_path,
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_set.py", line 549, in install
**kwargs
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_install.py", line 754, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_install.py", line 963, in move_wheel_files
isolated=self.isolated,
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/wheel.py", line 266, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/wheel.py", line 212, in clobber
shutil.copyfile(srcfile, destfile)
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/shutil.py", line 109, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/Users/qmbp/.virtualenvs/demo/bin/django-admin.py'
I guess the issue is caused as I did not prefix sudo to the command. But I read that it was a good idea to use sudo in OSX. And that is why virtualenv is encouraged as sudo is not needed inside it.Here is a screenshot of my files as I could not find the "env" in the bin folder.
Looks like you forgot to activate your venv.
Try:
source path_to_your_venv/bin/activate
pip install django

Categories

Resources