Pip spitting UnicodeDecode error - python

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

Related

'Module' has no attritube 'Treestyle'

If found some hits on stackoverflow where people have issues using ete3 tools when PyQT4 is not installed, and this (used to) also apply for me. However, I've now tried to reinstall a piece of software and it keeps complaining about 'Module' has no attritube 'Treestyle'.
To test whether PyQT was installed, I ran this python script:
from PyQt4.Qt import PYQT_VERSION_STR
print("PyQt version:", PYQT_VERSION_STR)
Which prints:
('PyQt version:', '4.12.1')
I get this (common) error:
Traceback (most recent call last):
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1820, in <module>
sys.exit(main())
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1793, in main
args.start(args)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 408, in start_evo_sim
result = init_and_simulate(simu, intermediate_load_file, _options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 117, in wrapper
raise ex_type(message)
AttributeError: 'module' object has no attribute 'TreeStyle' (in subprocess)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 91, in process_func
ret = func(*args, **kwargs)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 295, in init_and_simulate
sim = sim_mod.create_simulation(**options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1940, in create_simulation
sim = ODE_simulation(params_dict)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1342, in __init__
super(ODE_simulation, self).__init__(params)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 86, in __init__
self.init_graphs()
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 795, in init_graphs
show=show, clean=clean, create=create)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1188, in __init__
self.init_phylo_tree_graph(clean=clean)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1219, in init_phylo_tree_graph
show=show, attribute_dict=self.attribute_mapper, create=clean, **kwargs)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 985, in __init__
self.init_tree_style_dict() # NOTE: unordered ok
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1110, in init_tree_style_dict
branch_vertical_margin=branch_vertical_margin)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1083, in make_tree_style
ts = ete3.TreeStyle()
Note: this time arround I am trying to install it on Ubuntu for Windows, but up till now almost everything that ran on Linux ran on this one too. It might be relevent though.
Any ideas?
PS To reproduce the problem, follow the following steps:
$ sudo apt-get install python-qt4
$ virtualenv ~/mypy --system-site-packages
$ source ~/mypy/bin/activate
$ (mypy) > pip install VirtualMicrobes
$ (mypy) > virtualmicrobes evo --name TestMicrobes >> error
PPS User eyllanesc confirmed this is an 'Ubuntu for Windows' problem. I'm still trying to fix it though, if anyone can help me figure out how to link the pyqt4 packages correctly to my virtualenv that would be great. I've tried linken the native one with ln -s but I'm not getting any further
I had similar issues. The problem might be that you don't have all the depencies installed and ete3 is not telling you all of them.
You can see which dependencies are missing with this code:
import ete3
ete3.__file__
Run it and it will tell you which dependencies are missing. Note that you might need to run it multiple times before you install them all!

Python Error when installing ruamel.yaml package with pip

I am receiving an error when I want to install the ruamel.yaml package
Here is the command:
python --version;pip --version;pip install ruamel.yaml
And the output:
Python 2.7.10
pip 10.0.0 from /Library/Python/2.7/site-packages/pip (python 2.7)
Collecting ruamel.yaml
Downloading https://files.pythonhosted.org/packages/c1/ad/9557a78f1b61951623c56225e05dacdd81f80519f13fc39a926a5793edfa/ruamel.yaml-0.15.37.tar.gz (280kB)
100% |████████████████████████████████| 286kB 4.4MB/s
Complete output from command python setup.py egg_info:
sys.argv ['-c', 'egg_info', '--egg-base', 'pip-egg-info']
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/8j/69k5q3yn4y51g5nt2g7g9b9n24s68p/T/pip-install-htyM8C/ruamel.yaml/setup.py", line 917, in <module>
main()
File "/private/var/folders/8j/69k5q3yn4y51g5nt2g7g9b9n24s68p/T/pip-install-htyM8C/ruamel.yaml/setup.py", line 905, in main
setup(**kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 272, in __init__
_Distribution.__init__(self,attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 326, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2385, in require
reqs = self.dist.requires(self.extras)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2617, in requires
dm = self._dep_map
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2606, in _dep_map
if invalid_marker(marker):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1424, in is_invalid_marker
cls.evaluate_marker(text)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1549, in _markerlib_evaluate
env = cls._translate_metadata2(_markerlib.default_environment())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1537, in _translate_metadata2
for key, value in env
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1536, in <genexpr>
(key.replace('.', '_'), value)
ValueError: too many values to unpack
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/8j/69k5q3yn4y51g5nt2g7g9b9n24s68p/T/pip-install-htyM8C/ruamel.yaml/
To give a bit of a background. I installed python3 with brew and I uninstalled it thereafter.
Now I cannot install ruamel.yaml
Has anybody had the same issue?
How did you solve it?
You should do a pip list and check your version of setuptools should be (28.8.0). If you have an older version, upgrade with pip install -U setuptools.
You should consider upgrading from 2.7.10 to a newer version of Python 2 (currently 2.7.14), which should solve your SSL problems. Make sure you don't overwrite the system python if you are running on Linux.
I was able to resolve this by downgrading the python version from 3.10.+ to 3.9.+

UnicodeDecodeError when instaling new package

I am trying to install a package that I have used many times with python 2.7 and ubuntu 14.04, however it fails now with following error:
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 582, in unpack_http_url
unpack_file(temp_location, location, content_type, link)
File “/usr/lib/python2.7/dist-packages/pip/util.py”, line 643, in unpack_file
untar_file(filename, location)
File “/usr/lib/python2.7/dist-packages/pip/util.py”, line 574, in untar_file
path = os.path.join(location, fn)
File “/usr/lib/python2.7/posixpath.py”, line 80, in join
path += ‘/’ + b
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 47: ordinal not in range(128)
Storing debug log for failure in /home/ubuntu/.pip/pip.log
I googled around and it supposed to be a locale error, I managed to set locale to en_us.utf-8 it didn’t change anything. I don’t understand much about these settings, so I don’t know what to do next.
Could anybody help me out with this?
The package name is AllAuth and it fails with any version, new old, everything fails.
Try this executing
export PYTHONIOENCODING=utf8
try this link. Might be helpful for you.
Make sure that the package you're trying to install is Python 2 compatible. More and more modules are migrated to Python 3 and the new version handles unicode characters differently than version 2.

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.

UnicodeDecodeError during pip installation on linux

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')

Categories

Resources