You are not logged in.

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

Registered: 2015-12-18
Posts: 12

[Solved] Relentless Python/Pip UnicodeDecodeError


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/", line 211, in main
    status =, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/", line 305, in run
  File "/usr/local/lib/python2.7/dist-packages/pip/", line 705, in build
  File "/usr/local/lib/python2.7/dist-packages/pip/req/", line 334, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "/usr/local/lib/python2.7/dist-packages/pip/req/", line 321, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "/usr/local/lib/python2.7/dist-packages/pip/req/", line 505, in _prepare_file
  File "/usr/local/lib/python2.7/dist-packages/pip/req/", line 123, in prep_for_dist
  File "/usr/local/lib/python2.7/dist-packages/pip/req/", line 376, in run_egg_info
  File "/usr/local/lib/python2.7/dist-packages/pip/req/", line 347, in setup_py
    import setuptools  # noqa
  File "/usr/local/lib/python2.7/dist-packages/setuptools/", line 12, in <module>
    from setuptools.extension import Extension
  File "/usr/local/lib/python2.7/dist-packages/setuptools/", line 8, in <module>
    from .dist import _get_unpatched
  File "/usr/local/lib/python2.7/dist-packages/setuptools/", line 19, in <module>
    import pkg_resources
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 3138, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 3124, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 3151, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 652, in _build_master
    ws = cls()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 645, in __init__
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 701, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 2139, in find_on_path
    path_item, entry, metadata, precedence=DEVELOP_DIST
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 2521, in from_location
    py_version=py_version, platform=platform, **kw
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", 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/", line 2486, in _version_from_file
    line = next(iter(version_lines), '')
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 2654, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 2030, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/", line 2025, in get_metadata
    metadata =
  File "/usr/lib/python2.7/", 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.


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


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

Middle Office
Registered: 2015-09-29
Posts: 2,354

Re: [Solved] Relentless Python/Pip UnicodeDecodeError

Possibly something to do with a yellow "warning" block of tekst here


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

Registered: 2015-09-29
Posts: 5,534

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.

Give to COVAX! Here or here. (explanation)


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

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)


Board footer

Powered by FluxBB