Raspberry python3.4 pip error unknown encoding cp437 - python

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.

Related

Can't seem to use PIP to install my own module

I am following the 2nd edition of Head First Python by Paul Barry to try and learn to use python. I've made it to a point where I have created a function, put it in a module, then created a distribution file for that modules. Now I want to install it on my computer, but I can't seem to get the distribution file to run on my computer.
My code inserted into Windows 10 command prompt and the resulting errors:
C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\mymodules\dist> py -3 -m pip install vlsearch-1.0.tar
Requirement 'vlsearch-1.0.tar' looks like a filename, but the file does not exist
Processing c:\users\coolt\appdata\local\programs\python\python36-32\mymodules\dist\vlsearch-1.0.tar
Exception:
Traceback (most recent call last):
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\download.py", line 809, in unpack_url
unpack_file_url(link, location, download_dir, hashes=hashes)
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\download.py", line 715, in unpack_file_url
unpack_file(from_path, location, content_type, link)
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\utils\__init__.py", line 602, in unpack_file
tarfile.is_tarfile(filename) or
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\tarfile.py", line 2448, in is_tarfile
t = open(name)
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\tarfile.py", line 1569, in open
return func(name, "r", fileobj, **kwargs)
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\tarfile.py", line 1634, in gzopen
fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
File "C:\Users\coolt\AppData\Local\Programs\Python\Python36-32\lib\gzip.py", line 163, in __init__
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\coolt\\AppData\\Local\\Programs\\Python\\Python36-32\\mymodules\\dist\\vlsearch-1.0.tar'
You are using pip version 9.0.3, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I'm very confused because the file definitely exists in the spot that I am specifying. How do I get it installed?
the file exists in the folder that I expect it to

Hit ctrl-c during a pip install of spacy, now getting error when attempt to install again

I am trying to install spacy. I am on CentOS Linux
!pip install -U spacy
in a jupyter notebook and everything was working fine. During the installation, I realized I intended to include the --user command since I intended to install for my user only, so I hit ctrl-c. At this point the installation is incomplete.
Trying to install the package again with pip is now giving me an error, regardless of whether I include the --user flag. I think the error, below, is related to the incomplete build. Does anyone know how to fix this?
Collecting spacy
Exception:
Traceback (most recent call last):
File "/opt/anaconda2/lib/python2.7/site-packages/pip/basecommand.py", line
215, in main
status = self.run(options, args)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/commands/install.py",
line 335, in run
wb.build(autobuilding=True)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/wheel.py", line 749, in
build
self.requirement_set.prepare_files(self.finder)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/req/req_set.py", line
380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/opt/anaconda2/lib/python2.7/site-packages/pip/req/req_set.py", line
620, in _prepare_file
session=self.session, hashes=hashes)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/download.py", line 809,
in unpack_url
unpack_file_url(link, location, download_dir, hashes=hashes)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/download.py", line 715,
in unpack_file_url
unpack_file(from_path, location, content_type, link)
File "/opt/anaconda2/lib/python2.7/site-packages/pip/utils/__init__.py",
line 599, in unpack_file
flatten=not filename.endswith('.whl')
File "/opt/anaconda2/lib/python2.7/site-packages/pip/utils/__init__.py",
line 484, in unzip_file
zip = zipfile.ZipFile(zipfp, allowZip64=True)
File "/opt/anaconda2/lib/python2.7/zipfile.py", line 770, in __init__
self._RealGetContents()
File "/opt/anaconda2/lib/python2.7/zipfile.py", line 811, in _
RealGetContents
raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file`
Thanks everyone. A solution that worked for me was to go to $HOME/.cache/pip and delete the contents of http/ and wheels/

Pip install failure for tensorflow-gpu - OSError: raw write() returned invalid length

When installing tensorflow-gpu 1.4.0 using pip in Windows 10 (Python 3.5), I get the following strange error. Very interestingly, each time I run
pip.exe install tensorflow-gpu
it downloads a small but seemingly random part of the package, then raises the following exception:
(C:\Users\carth\Anaconda3\envs\py35) E:\Data\ownCloud\Work\CoronaryML>pip.exe install tensorflow-gpu
Collecting tensorflow-gpu
Downloading tensorflow_gpu-1.4.0-cp35-cp35m-win_amd64.whl (67.6MB)
Exception: | 266kB 797kB/s eta 0:01:25
Traceback (most recent call last):
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 821, in unpack_url
hashes=hashes
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 659, in unpack_http_url
hashes)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 882, in _download_http_url
_download_url(resp, link, content_file, hashes)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\utils\hashes.py", line 46, in check_against_chunks
for chunk in chunks:
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\download.py", line 571, in written_chunks
for chunk in chunks:
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\utils\ui.py", line 141, in iter
self.next(n)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\progress\__init__.py", line 73, in next
self.update()
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\progress\bar.py", line 41, in update
self.writeln(line)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\progress\helpers.py", line 67, in writeln
self.clearln()
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\progress\helpers.py", line 63, in clearln
print('\r\x1b[K', end='', file=self.file)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\colorama\ansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\colorama\ansitowin32.py", line 166, in write_and_convert
self.write_plain_text(text, cursor, start)
File "C:\Users\carth\Anaconda3\envs\py35\lib\site-packages\pip\_vendor\colorama\ansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
OSError: raw write() returned invalid length 2 (should have been between 0 and 1)
I tried turning off my antivirus, in case that was killing it, but it didn't help.
In the end, I managed to install it by downloading the .whl from PyPI manually, then running pip.exe install path/to/.whl, but I'd like to understand what caused the original failure.
Any ideas?
This issue has been documented here, you can update to python 3.6 or install and enable the win_unicode_console package to solve it
https://bugs.python.org/issue32245
Switch to cmd with administrator rights to run the command:
pip3 install --ignore-installed --upgrade tensorflow-gpu -i https://pypi.tuna.
tsinghua.edu.cn/simple

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.

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

Categories

Resources