PIP Install Numpy throws an error "ascii codec can't decode byte 0xe2"
Solution 1
I had this exact problem recently and used
apt-get install python-numpy
This adds numpy to your system python interpreter. I may have had to do the same for matplotlib. To use in a virtualenv, you have to create your environment using the
--system-site-packages
option
http://www.scipy.org/install.html
Solution 2
For me @Charles Duffy comment solved it. Put this in your env:
LC_ALL=C
You can add it to your .bashrc with a line like this:
export LC_ALL=C
But take in care that you'll affect all other programs. So you may want to use it just for the pip run:
$ LC_ALL=C pip install ...
Solution 3
Try updating pip:
pip install -U pip
Solution 4
I had that problem with matplotlib package. I had to execute:
export LC_ALL=C
pip install --upgrade setuptools
Solution 5
For me this was solved by ignoring a (presumably) corrupted cache with
pip install --no-cache-dir ...
as described here: https://github.com/pypa/pip/issues/2674
Josh.F
Updated on June 01, 2020Comments
-
Josh.F almost 4 years
I have a freshly installed Ubuntu on a freshly built computer. I just installed python-pip using apt-get. Now when I try to pip install Numpy and Pandas, it gives the following error.
I've seen this error mentioned in quite a few places on SO and Google, but I haven't been able to find a solution. Some people mention it's a bug, some threads are just dead... What's going on?
Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> load_entry_point('pip==1.5.4', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 185, in main return command.main(cmd_args) File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main text = '\n'.join(complete_log) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 72: ordinal not in range(128)
-
Josh.F over 9 yearsThanks! Also, I found that if python-dev doesn't come stock on the computer, you need that too
-
Jeff M. over 9 yearsYeah. I remember that now.. Good catch.
-
fiatjaf over 9 yearsYou don't need to recreate your
virtualenv
, you can modify an existing one withvirtualenv VIRTUALENV_DIR --system-site-packages
. -
hello_there_andy over 9 yearsthis fixed the same error I had with pip install scipy, thanks
-
tourdownunder over 9 yearsSame here. Upgraded VM instance from 1 to a 2 gig RAM temporarily while installing.
-
baltasvejas almost 9 yearsHad same issue on Ubuntu server 14.02.
sudo apt-get install python2.7-dev
solved the issue. -
Mark almost 9 yearsThis solves the problem but I think you should at least mention you are making (all) system packages available, so the point of using virtualenv is partially defeated...
-
moi almost 9 yearsThis seems to be the correct answer. Using
--system-site-packages
was not an option for me. -
user1158559 about 8 yearsThis is only an indirect answer, but it teaches something and does not deserve to be downvoted.
-
Gil Hiram almost 8 yearsa better wording for you answer would be: add "export LC_ALL=C" to your ~/.bashrc
-
msemelman almost 8 years@GilHiram Depends on your shell type you may have to set up this env variable in other places. unix.stackexchange.com/questions/50665/…
-
Arjun over 7 yearsThe install didn't work for me both within, and outside a virtualenv so using
--system-site-packages
was not the right answer. I got it to work inside a virtualenv withLC_ALL=C pip install ...
. -
kalebo about 7 yearsThis worked for me on debian jessie inside of a venv.
-
WestCoastProjects almost 7 yearswhat does
export LC_ALL=C
mean / do ? -
radtek over 6 years@javadba It forces applications to use the default language for output, and forces sorting to be bytewise.
-
Barmaley over 5 years
locale-gen en_US.UTF-8
worked for me as well! OrRUN locale-gen en_US.UTF-8
in Dockerfile