UnicodeDecodeError during pip installation on linux - python

On Red Hat 4.8 with python 2.7.5 during installation pip 9.0.1 with command
pip install --upgrade pip
I get this error:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 272, in run
with self._build_session(options) as session:
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/lib/python2.7/site-packages/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/lib/python2.7/site-packages/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/usr/lib/python2.7/site-packages/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/usr/lib/python2.7/site-packages/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/usr/lib/python2.7/site-packages/pip/_vendor/distro.py", line 922, in _get_lsb_release_info
stdout, stderr = stdout.decode('utf-8'), stderr.decode('utf-8')
File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xea in position 22: invalid continuation byte
Some commands of pip work as they should, for example, pip list shows the information, but
in the end it also shows traceback as above.
pip install pandas doesn't work at all.
pip --version command shows:
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)
Also I cannot install the previous version with command:
pip install pip=8.1.1
Does this mean that installation failed or I need just
make some changes to make pip work properly?
(By the way all locales are cp1251)

I think, you need to change the default encoding of your systems,
this code allow you to change it to 'ISO-8859-1':
import sys
reload(sys)
sys.setdefaultencoding('ISO-8859-1')

Related

"codec can't encode character" error when I run "pipx install eth-brownie"

Not sure if this helps but I couldn't run "python3 -m pip install --user pipx" and "python3 -m pipx ensurepath". Instead of "python3" I just used "python" and also ran "python -m pipx ensurepath --force"
It told me pipx is ready to go and then I ran "pipx install eth-brownie" and got the below.
C:\Users\gmlad>pipx install eth-brownie
Traceback (most recent call last):
File "E:\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "E:\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\users\gmlad\appdata\roaming\python\python310\scripts\pipx.exe\__main__.py", line 7, in <module>
File "C:\Users\gmlad\AppData\Roaming\Python\Python310\site-packages\pipx\main.py", line 779, in cli
return run_pipx_command(parsed_pipx_args)
File "C:\Users\gmlad\AppData\Roaming\Python\Python310\site-packages\pipx\main.py", line 202, in run_pipx_command
return commands.install(
File "C:\Users\gmlad\AppData\Roaming\Python\Python310\site-packages\pipx\commands\install.py", line 60, in install
venv.install_package(
File "C:\Users\gmlad\AppData\Roaming\Python\Python310\site-packages\pipx\venv.py", line 238, in install_package
subprocess_post_check_handle_pip_error(pip_process)
File "C:\Users\gmlad\AppData\Roaming\Python\Python310\site-packages\pipx\util.py", line 349, in subprocess_post_check_handle_pip_error
print(completed_process.stderr, file=pip_error_fh, end="")
File "E:\Python310\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2502' in position 559: character maps to <undefined>
You can try to install brownie by clone from github repository like blow. Then after that you can delete all the code if you want. And you already can use the brownie cli on your computer.
git clone https://github.com/eth-brownie/brownie.git
cd brownie
python3 setup.py install
Try upgrading pip using:
python -m pip install --upgrade pip
If that doesn't work, then you might need to set your locale to UTF-8. There is a closed GitHub issue on the pipx repo regarding this issue: https://github.com/pypa/pipx/issues/73.

UnicodeDecodeError when trying to upgrade "pip" or "install pywinusb"

I'm trying to upgrade pip, and also install pywinusb, but I'm getting the error: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 8: ordinal not in range(128)".
Pip upgrade:
PS C:\Python27> pip --version
pip 18.1 from c:\python27\lib\site-packages\pip (python 2.7)
PS C:\Python27> python -m pip install --upgrade pip
Collecting pip
Exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\_internal\commands\install.py", line 318, in run
resolver.resolve(requirement_set)
File "C:\Python27\lib\site-packages\pip\_internal\resolve.py", line 102, in resolve
self._resolve_one(requirement_set, req)
File "C:\Python27\lib\site-packages\pip\_internal\resolve.py", line 256, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:\Python27\lib\site-packages\pip\_internal\resolve.py", line 209, in _get_abstract_dist_for
self.require_hashes
File "C:\Python27\lib\site-packages\pip\_internal\operations\prepare.py", line 283, in prepare_linked_requirement
progress_bar=self.progress_bar
File "C:\Python27\lib\site-packages\pip\_internal\download.py", line 836, in unpack_url
progress_bar=progress_bar
File "C:\Python27\lib\site-packages\pip\_internal\download.py", line 673, in unpack_http_url
progress_bar)
File "C:\Python27\lib\site-packages\pip\_internal\download.py", line 895, in _download_http_url
file_path = os.path.join(temp_dir, filename)
File "C:\Python27\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 8: ordinal not in range(128)
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
And in "pywinusb" install:
PS C:\Python27> pip install pywinusb
Collecting pywinusb
Exception:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
status = self.run(options, args)
File "c:\python27\lib\site-packages\pip\_internal\commands\install.py", line 318, in run
resolver.resolve(requirement_set)
File "c:\python27\lib\site-packages\pip\_internal\resolve.py", line 102, in resolve
self._resolve_one(requirement_set, req)
File "c:\python27\lib\site-packages\pip\_internal\resolve.py", line 256, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "c:\python27\lib\site-packages\pip\_internal\resolve.py", line 209, in _get_abstract_dist_for
self.require_hashes
File "c:\python27\lib\site-packages\pip\_internal\operations\prepare.py", line 283, in prepare_linked_requirement
progress_bar=self.progress_bar
File "c:\python27\lib\site-packages\pip\_internal\download.py", line 836, in unpack_url
progress_bar=progress_bar
File "c:\python27\lib\site-packages\pip\_internal\download.py", line 673, in unpack_http_url
progress_bar)
File "c:\python27\lib\site-packages\pip\_internal\download.py", line 895, in _download_http_url
file_path = os.path.join(temp_dir, filename)
File "c:\python27\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 8: ordinal not in range(128)
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Before this I have installed the package "pyusb" without any problem, without getting any error.
I've searched in google for this error, but not getting a very good explanation.
How to solve this error?
This occurs if your current working directory has name with non ASCII characters.Example ¢, Ë, Ñ, ß etc.
Remove those from the directory or file name and you are good to go.
About this particular error: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 8: ordinal not in range(128)", when trying to upgrade pip or install any python packet, was related to the user folder name.
My user folder name was "C:/Users/Sérgio Neves", and the "é" in "Sérgio" was the problem, so I changed the user folder name to "C:/Users/SergioNeves", without any accent and space.
I followed this video to change the folder name:
https://www.youtube.com/watch?v=J_rTOA4gXJI

when install OSMnx get erroe "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 24: invalid continuation byte"

I have Python 3.6.1 32 bit,
OS windows 10 x64,
Tried install
pip install OSMnx
get error
Exception:
Traceback (most recent call last):
File "C:\Users\liuzi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\compat__init__.py", line 73, in console_to_str
return s.decode(sys.stdout.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 24: invalid continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\liuzi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\liuzi\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\liuzi\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\liuzi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\req\req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "C:\Users\liuzi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\req\req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "C:\Users\liuzi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\req\req_install.py", line 439, in run_egg_info
command_desc='python setup.py egg_info')
File "C:\Users\liuzi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\utils__init__.py", line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File "C:\Users\liuzi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\compat__init__.py", line 75, in console_to_str
return s.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 24: invalid continuation byte
The OSMnx installation instructions suggest using conda-forge to install. This is particularly important on Windows, as you want to avoid compiling all the C extensions required by the geospatial dependencies.
conda install -c conda-forge osmnx
Or if all else fails, do the install in a nice clean virtual environment:
conda create --yes -c conda-forge -n OSMNX python=3 osmnx
source activate OSMNX
That should solve any Windows-related install problems (and works for Mac and Linux too).

Pip spitting UnicodeDecode error

I'm not 100% positive as to what is the correct place to post this question since it's 50% programming since it's a python bug and 50% system management, since it's a bug on a package. I went on to post here, If I'm incorrect please direct me to the right place.
I'm currently running Arch Linux 64 bit and earlier today I updated a couple of packages including the (critical I believe) python-setuptools. Before this pip worked perfectly, no issues whatsoever, now however just from running the bare command I get the following:
espaco#Arch ~> pip
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3143, in <module>
#_call_aside
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3129, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3156, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 649, in _build_master
ws = cls()
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 642, in __init__
self.add_entry(entry)
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 698, in add_entry
for dist in find_distributions(entry, True):
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2136, in find_on_path
path_item, entry, metadata, precedence=DEVELOP_DIST
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2518, in from_location
version = cls._version_from_metadata(dist_path) or version
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2841, in _version_from_metadata
return _version_from_file(strm)
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2483, in _version_from_file
line = next(iter(version_lines), '')
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 116: ordinal not in range(128)
Is this something I did wrong or does pip have a bug? How would I be able to fix this?
What I have tried:
Reinstalling pip
Reinstalling python-setuptools
The almighty reboot
Ask my mom to kiss bash in the forehead
Search the Arch package list for a bug report
Google the problem
$ ll /var/cache/pacman/pkg/python-setuptools-*
then select desired version, and
$ sudo pacman -U /var/cache/pacman/pkg/python-setuptools-1:18.7-1-any.pkg.tar.xz
where 1:18.7-1 is your previous version of the package
if it will not help:
$ cat /var/log/pacman.log | grep 2015-11-30 | grep upgraded
and then for each package install it's previous version by doing part 1
you can write a script for that or find existing.
also try to search arch community forums

Python pip install error

I have just installed Python 3.4.3 on my MAC (Yosemite). I need to install a couple of lxml, however everytime I type in: pip install /""/, I get error messages.
I have followed multiple tutorials and pip is installed.
MAC already had Python 2.7., but I installed the 3.4.3. version, not sure if that is the issue.
The error message is:
Brunos-MacBook-Pro:~ BrunoPaesLeme$ pip install /Macintosh HD/Users//Downloads/pycairo-1.10.0-cp27-none-win_amd64.whl
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/commands/install.py", line 268, in run
wheel_cache
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/basecommand.py", line 268, in populate_requirement_set
wheel_cache=wheel_cache
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_install.py", line 207, in from_line
wheel_cache=wheel_cache)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_install.py", line 66, in init
req = pkg_resources.Requirement.parse(req)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/_vendor/pkg_resources/init.py", line 2960, in parse
reqs = list(parse_requirements(s))
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/_vendor/pkg_resources/init.py", line 2891, in parse_requirements
raise ValueError("Missing distribution spec", line)
ValueError: ('Missing distribution spec', '/Macintosh')
Anybody knows what I could be doing wrong? Any help would be appreciated.
try:
easy_install pip
pip install /"filepath"/
I have similar issue with pip install. However, if I do "sudo su -" then do my pip install 'fileName', that solve the problem for me.

Categories

Resources