Python 3.4 和 2.7:无法为 Python 3.4 安装 numpy 包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24892810/
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
Python 3.4 and 2.7: Cannot install numpy package for python 3.4
提问by SmCaterpillar
I am using Ubuntu 12.04 and want to use python 3.4 side by side with python 2.7.
我正在使用 Ubuntu 12.04 并希望将 python 3.4 与 python 2.7 并排使用。
The installation of python 3.4 worked properly. However, I cannot install the numpy package for python 3 (and as a consequence I can't install scipy, pandas etc.).
python 3.4的安装工作正常。但是,我无法为 python 3 安装 numpy 包(因此我无法安装 scipy、pandas 等)。
Using
使用
sudo pip3 install numpy
spits out the following error:
吐出以下错误:
File "numpy/core/setup.py", line 289, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
Btw, I already have python-dev installed.
顺便说一句,我已经安装了 python-dev。
Moreover, installing numpy via
此外,通过安装numpy
sudo apt-get install python-numpy
does not work either since I already installed numpy for python 2.7 and the installer responds that numpy is already up to date.
也不起作用,因为我已经为 python 2.7 安装了 numpy 并且安装程序响应 numpy 已经是最新的。
What can I do? Thanks!
我能做什么?谢谢!
采纳答案by Martijn Pieters
You have not installed the Python 3 development package. Install python3.4-dev
:
您尚未安装 Python 3开发包。安装python3.4-dev
:
apt-get install python3.4-dev
The main package never includes the development headers; Debian (and by extension Ubuntu) package policy is to put those into a separate -dev
package. To install numpy
however, you need these files to be able to compile the extension.
主包从不包含开发头文件;Debian(以及扩展的 Ubuntu)包策略是将它们放入一个单独的-dev
包中。numpy
但是,要安装,您需要这些文件才能编译扩展。