Python PIP 安装 Numpy 抛出错误“ascii 编解码器无法解码字节 0xe2”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26473681/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PIP Install Numpy throws an error "ascii codec can't decode byte 0xe2"
提问by Josh.F
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.
我在一台新造的电脑上安装了一个新安装的 Ubuntu。我刚刚使用 apt-get 安装了 python-pip。现在,当我尝试 pip install Numpy 和 Pandas 时,出现以下错误。
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?
我在 SO 和 Google 上的很多地方都看到了这个错误,但我一直找不到解决方案。有些人提到这是一个错误,有些线程已经死了……这是怎么回事?
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)
采纳答案by Jeff M.
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
这将 numpy 添加到您的系统 python 解释器中。我可能不得不为 matplotlib 做同样的事情。要在 virtualenv 中使用,您必须使用
--system-site-packages
option
选项
回答by Toby Seo
In 'site-packages' directory, make 'sitecustomize.py' like this
在“site-packages”目录中,像这样制作“sitecustomize.py”
import sys
sys.setdefaultencoding("utf-8")
Now you can get the file 'pip.log'
现在你可以得到文件'pip.log'
回答by Selah
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.
我在运行时遇到了类似的错误pip install pandas,这是由于内存不足造成的。我将虚拟机中的内存增加到 4G 并解决了问题。
回答by msemelman
For me @Charles Duffy comment solved it. Put this in your env:
对我来说,@Charles Duffy 评论解决了这个问题。把它放在你的环境中:
LC_ALL=C
LC_ALL=C
You can add it to your .bashrc with a line like this:
您可以使用如下一行将其添加到 .bashrc 中:
export LC_ALL=C
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:
但请注意,您会影响所有其他程序。因此,您可能只想将它用于 pip 运行:
$ LC_ALL=C pip install ...
$ LC_ALL=C pip install ...
回答by max
I had that problem with matplotlib package. I had to execute:
我遇到了 matplotlib 包的问题。我必须执行:
export LC_ALL=C
pip install --upgrade setuptools
回答by Tavleen
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)
试试sudo apt-get install python-numpy。它对我有用,同样可以用于 scipy、pandas 等,通过替换它们代替 numpy。(是)
回答by Ali
A combination of
组合
sudo apt-get install python-dev
and
和
export LC_ALL=C
pip install --upgrade setuptools
solved my problem.
解决了我的问题。
回答by arinarmo
If you want the pip version of numpy, you can build the dependencies for the package and then install it using pip
如果你想要 numpy 的 pip 版本,你可以构建包的依赖项,然后使用 pip 安装它
sudo apt-get build-dep python-numpy
pip install numpy
This should install everything needed at system level to install the package.
这应该安装在系统级别安装软件包所需的一切。
回答by jvd10
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
回答by rafaelvalle
Had a similar problem on a Jetson TK1 with Ubuntu.
在 Jetson TK1 和 Ubuntu 上有类似的问题。
Works fine with apt-get install python-pandas
工作正常 apt-get install python-pandas

