You are not logged in.

#1 2015-12-28 20:56:09

mastokley
Member
Registered: 2015-12-18
Posts: 12

[Solved] Relentless Python/Pip UnicodeDecodeError

Hello,

I've been getting the following error non-stop over the past few days as I try to install and test pip, virtualenv, and virtualenvwrapper:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 305, in run
    wb.build(autobuilding=True)
  File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 705, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 334, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 321, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 505, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 123, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 376, in run_egg_info
    self.setup_py, self.name,
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 347, in setup_py
    import setuptools  # noqa
  File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 12, in <module>
    from setuptools.extension import Extension
  File "/usr/local/lib/python2.7/dist-packages/setuptools/extension.py", line 8, in <module>
    from .dist import _get_unpatched
  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 19, in <module>
    import pkg_resources
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3138, in <module>
    @_call_aside
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3124, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3151, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 652, in _build_master
    ws = cls()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 645, in __init__
    self.add_entry(entry)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 701, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2139, in find_on_path
    path_item, entry, metadata, precedence=DEVELOP_DIST
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2521, in from_location
    py_version=py_version, platform=platform, **kw
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2835, in _reload_version
    md_version = _version_from_file(self._get_metadata(self.PKG_INFO))
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2486, in _version_from_file
    line = next(iter(version_lines), '')
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2654, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2030, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2025, in get_metadata
    metadata = f.read()
  File "/usr/lib/python2.7/codecs.py", line 296, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb6 in position 147: invalid start byte

It's hard to pin down whether this is a Python issue or a pip issue or a debian issue... I've uninstalled and reinstalled python and pip many times.

Originally, it was so bad that I could not even run

pip --version

without receiving the error. Forcing pip to upgrade seems to have solved that.

Most recently, I got the error after trying to install matplotlib using

pip install matplotlib

.

I recently switched from Crunchbang to BunsenLabs 8.2... could it be a Debian 8 issue? I never got these problems on Crunchbang.

The UnicodeDecodeError *always* includes that last line verbatim (UnicodeDecodeError: 'utf8' codec can't decode byte 0xb6 in position 147: invalid start byte).

Note: I did attempt the solution outlined here, but it did not work.

Version and system info:
- python 2.7.9
- pip 7.1.2
- virtualenv 13.1.2
- machine is thinkpad t430
- os BunsenLabs GNU/Linux 8.2 (Hydrogen)

Any thoughts you might have would be greatly appreciated! More than happy to provide additional info, as well. Any leads on what topic to research next would be especially appreciated.

Sincerely,
Michael

Last edited by mastokley (2015-12-31 22:23:58)

Offline

#2 2015-12-29 10:13:08

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,152
Website

Re: [Solved] Relentless Python/Pip UnicodeDecodeError

Possibly something to do with a yellow "warning" block of tekst here
https://virtualenv.readthedocs.org/en/latest/

Online

#3 2015-12-29 13:04:09

ohnonot
...again
Registered: 2015-09-29
Posts: 5,022
Website

Re: [Solved] Relentless Python/Pip UnicodeDecodeError

mastokley wrote:

I've been getting the following error non-stop over the past few days as I try to install and test pip, virtualenv, and virtualenvwrapper

i'm sorry i don't quite follow.
what did you install through debian's repos, what did you install with pip, and where exactly are you getting that error?
in other words, are packages installed through debian repos giving you trouble, or others?

my own delvings into python are very shallow, but i remember that it's famous for having difficulties with unicode / utf encoding.


Search youtube without a brwoser: repo | thread
BL quote proposals to this thread please.
my repos / my repos

Offline

#4 2015-12-31 00:19:12

mastokley
Member
Registered: 2015-12-18
Posts: 12

Re: [Solved] Relentless Python/Pip UnicodeDecodeError

brontosaurusrex, thank you for pointing me there. That warning helped me understand this is a pathing issue from within the virtualenv.

When trying to install matplotlib via pip from within a virtualenv: I get the unicodeDecodeError when the virtualenv is in a subdirectory within my home directory; I do not get the error when the virtualenv was in /home/michael directly.

Also, when the virtualenv is within a subdirectory, I get the same output when running

pip freeze

from within the virtualenv and from outside; when the virtualenv is in /home/michael, the outputs are different. The python inside the virtualenv only has one package ('wheel'). I think that means it's pathing correctly to the virtual python environment.

EDIT: The pathing error was due to whitespace in a folder name.

Last edited by mastokley (2015-12-31 00:31:15)

Offline

Board footer

Powered by FluxBB