Python 3.4 和 2.7:无法为 Python 3.4 安装 numpy 包 [英] Python 3.4 and 2.7: Cannot install numpy package for python 3.4

查看:45
本文介绍了Python 3.4 和 2.7:无法为 Python 3.4 安装 numpy 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Ubuntu 12.04,并且想同时使用 python 3.4 和 python 2.7.

I am using Ubuntu 12.04 and want to use python 3.4 side by side with python 2.7.

python 3.4 安装正常.但是,我无法为 python 3 安装 numpy 包(因此我无法安装 scipy、pandas 等).

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.).

使用

 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-dev.

Btw, I already have python-dev installed.

此外,通过

 sudo apt-get install python-numpy

也不起作用,因为我已经为 python 2.7 安装了 numpy 并且安装程序响应说 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 3 开发包.安装python3.4-dev:

You have not installed the Python 3 development package. Install python3.4-dev:

apt-get install python3.4-dev

主包从不包含开发头文件;Debian(以及扩展的 Ubuntu)包策略是将它们放入一个单独的 -dev 包中.但是,要安装 numpy,您需要这些文件才能编译扩展.

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.

这篇关于Python 3.4 和 2.7:无法为 Python 3.4 安装 numpy 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆