Python3.4和2.7:无法为Python3.4安装numpy包

Python3.4和2.7:无法为Python3.4安装numpy包,python,numpy,ubuntu,pip,python-3.4,Python,Numpy,Ubuntu,Pip,Python 3.4,我正在使用Ubuntu12.04,并希望将Python3.4与Python2.7并排使用 python 3.4的安装工作正常。但是,我无法为Python3安装numpy包(因此我无法安装scipy等) 使用 sudo pip3 install numpy 抛出以下错误: File "numpy/core/setup.py", line 289, in check_types "Cannot compile 'Python.h'. Perhaps you need to "\ System

我正在使用Ubuntu12.04,并希望将Python3.4与Python2.7并排使用

python 3.4的安装工作正常。但是,我无法为Python3安装numpy包(因此我无法安装scipy等)

使用

 sudo pip3 install numpy
抛出以下错误:

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.
顺便说一句,我已经安装了python开发人员

此外,通过

 sudo apt-get install python-numpy
也不起作用,因为我已经安装了适用于Python2.7的numpy,并且安装程序响应numpy已经是最新的


我能做什么?谢谢

您尚未安装Python 3开发包。安装python3.4-dev:

apt-get install python3.4-dev

主包从不包含开发头文件;Debian(扩展到Ubuntu)软件包策略是将它们放在一个单独的
-dev
软件包中。然而,要安装
numpy
,您需要这些文件才能编译扩展名。

通过增加python开发包直到找到正确的扩展名来解决。将来可能需要进一步增加。 python开发人员的实现很差


sudo-apt-get-install-python3.7-dev

对于2015年出现类似查询的用户(如我所做的),需要将上述命令更改为
apt-get-install-python3.5-dev
。对于将来的任何人:调整该命令以适应当前的Python版本。是的,Ubuntu不会读懂你的心思或日历-Por您可以使用
安装python3 dev
,ubuntu会读懂您的心思,为您的ubuntu版本安装正确的point版本。@DaveLeBlanc:这取决于ubuntu版本的“当前”版本。在12.04,这不是3.4。你知道我如何在MSYS2中修复这个错误吗?我尝试安装mingw-w64-x86_64-python3,当我尝试使用pip安装numpy时,遇到了这个错误:
SystemError:无法编译“Python.h”。也许您需要安装python dev | python devel
您可以运行
sudo apt get install python3 dev
,它将安装与您的python3版本相对应的开发包。