虚拟环境virtualenv问题PIP Install Numpy throws an error “ascii codec can't decode byte 0xe2”
2018-01-17 18:48
417 查看
转换虚拟环境:
virtualenv VIRTUALENV_DIR
--system-site-packages
Ask
Question
来源: https://stackoverflow.com/questions/26473681/pip-install-numpy-throws-an-error-ascii-codec-cant-decode-byte-0xe2
activeoldestvotes
virtualenv VIRTUALENV_DIR
--system-site-packages
PIP
Install Numpy throws an error “ascii codec can't decode byte 0xe2”
AskQuestion
up vote63down votefavorite 9 | 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)
python numpy pandas pip
| |||||||||||||||||
a comment |
14 Answers
activeoldestvotesup vote43down voteaccepted | 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
| |||||||||||||||||||||
comment |
up vote32down vote | 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 ...
| ||||||||||||||||||||
a comment |
up vote8down vote | Try updating pip: |
pip install -U pip
| |||||
a comment |
up vote7down vote | I had that problem with matplotlib package. I had to execute: |
export LC_ALL=C
pip install --upgrade setuptools
| ||
add a comment |
up vote4down vote | 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
| ||
add a comment |
up vote3down vote | A combination of |
sudo apt-get install python-dev
and |
export LC_ALL=C
pip install --upgrade setuptools
solved my problem.
| |||
add a comment |
up vote3down vote | I had a similar error when running pip install pandasand it was due to a memory shortage. I increased the memory in my virtual machine to 4G and that fixed things.
| ||||
a comment |
up vote1down vote | In 'site-packages' directory, make 'sitecustomize.py' like this |
import sys
sys.setdefaultencoding("utf-8")
Now you can get the file 'pip.log'
| |||||
a comment |
up vote1down vote | try sudo apt-get install python-numpy. It worked out for me and same can be used for scipy,pandas etc by replacing them in place of numpy. (Y)
| ||
add a comment |
up vote0down vote | If you want the pip version of numpy, you can build the dependencies for the package and then install it using pip |
sudo apt-get build-dep python-numpy
pip install numpy
This should install everything needed at system level to install the package.
| ||
add a comment |
up vote0down vote | Had a similar problem on a Jetson TK1 with Ubuntu. Works fine with apt-get install python-pandas
| ||
add a comment |
up vote0down vote | So many answers and none worked for me even though some clearly worked for other people. But I then figured out what my problem was, so I'll just add it to the collection: |
dpkg-reconfigure locales
# enable the "en-US.UTF-8" locale
# when asked for a default, no need to define one
The thing is, I was working inside a Debian Stretch linux container that happened to not have any UTF-8 locales installed, probably because I downloaded a minimal stock image. With this UTF-8 locale now installed, pip properly installed numpy and other packages.
| ||
add a comment |
up vote0down vote | In my case I had just installed Python from source (on a remote machine where I am not sudo). For whatever reason, pipwas on some really old version. So after: |
python -m pip install --upgrade pip
I was able to install numpyand everything I wanted without trouble.
| ||
add a comment |
up vote0down vote | I met the similar problem. I tried: |
export LC_ALL=C
pip install --upgrade setuptools
But it did not solve the problem, but another error came up: AttributeError: 'str' object has no attribute 'rollback' Then I tried: |
pip install -U pip
Then the problem was solved. |
相关文章推荐
- pip install 出现UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 73: ordinal not i
- python用pip装第三方库numpy时报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7: ordi
- setuptools,pip,install,UnicodeDecodeError: 'ascii' codec can't decode byte.原因和解决方案
- Python2.7编码问题:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position...解决方法
- setuptools,pip,install,UnicodeDecodeError: 'ascii' codec can't decode byte.原因和解决方案
- python: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 20: ordinal not in rang
- sublime的Fatal pylint error: UnicodeDecodeError: 'ascii' codec can't decode byte 问题解决方案
- setuptools,pip,install,UnicodeDecodeError: 'ascii' codec can't decode byte.原因和解决方案
- pip install 安装出现问题:UnicodeEncodeError: 'ascii' codec can't encode characters in position XX的解决办法
- 记一次PIP执行出错--UnicodeDecodeError: 'ascii' codec can't decode byte 0xb1 in position 9: ordinal
- setuptools,pip,install,UnicodeDecodeError: 'ascii' codec can't decode byte.原因和解决方案
- 解决unicodedecodeerror ascii codec can’t decode byte 0xd7 in position 9 ordinal not in range(128)
- python | 读文件编码问题 | UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 34: illegal mu
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 1: ordinal not in range(128)
- Django UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6
- pip 安装pandas报UnicodeDecodeError: 'ascii' codec can't decode byte 0xd5错
- 解决unicodedecodeerror ascii codec can’t decode byte 0xd7 in position 9 ordinal not in range(128)
- 解决unicodedecodeerror ascii codec can’t decode byte 0xd7 in position 9 ordinal not in range(128)
- python处理windows文本报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4