在Linux Red Hat上安装NumPy时出现的错误

14
我正在尝试从http://www.scipy.org/Download下载numpy。通过git clone git://github.com/numpy/numpy.git numpy进行安装。但是,当我运行python setup.py install时,出现以下错误:SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel。请问如何获取python-dev?我已经尝试了:
$ easy_install python-devel
Searching for python-devel
Reading http://pypi.python.org/simple/python-devel/
Couldn't find index page for 'python-devel' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for python-devel
error: Could not find suitable distribution for Requirement.parse('python-devel')

而且
$ easy_install python-dev
Searching for python-dev
Reading http://pypi.python.org/simple/python-dev/
Couldn't find index page for 'python-dev' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for python-dev
error: Could not find suitable distribution for Requirement.parse('python-dev')

任何帮助都会受到赞赏。
为了解决 python-dev 的问题,我在本地目录中安装了 python2.6。
但是,当我使用 python setup.py install --user 安装 numpy 时,
我得到了以下错误信息: $ python setup.py install --user 'import site' 失败;
使用 -v 来获取 traceback。Traceback (most recent call last): File "setup.py", line 18,
in import os ImportError:
没有找到 os 模块
在 python2.6 中,我得到了以下信息:
>>> import os Traceback (most recent call last): File "", line 1, in ImportError: No module named os
任何帮助都会受到赞赏。谢谢。
以下链接并不有用,因为我没有 root 权限,无法使用 sudo。 example1 example2

你使用的是哪个Linux发行版? - Keith
你可以询问拥有管理员权限(root)的人是否可以安装那个软件包吗? - Keith
我不是root用户,无法使用sudo。我必须将其安装在我的本地目录中。 - runner frank
3个回答

15

如果您使用的是Ubuntu(例如Ubuntu 12.04),那么非常容易,

sudo apt-get install python-numpy
或者你可以通过pip从源代码编译(我认为在RedHat上几乎是一样的):

或者你可以通过pip从源代码编译(我认为在RedHat上几乎是一样的):

sudo apt-get install python-dev  
sudo apt-get install python-pip  
pip install numpy

4
OP 没有 root 权限,正在使用红帽系统(使用 yum 而不是 apt-get)。 - tacaswell

7

python-dev不是Python模块。实际上,它是“用于构建Python模块、扩展Python解释器或将Python嵌入应用程序的头文件、静态库和开发工具。”您可以通过Synaptic软件包管理器、软件中心或yum安装它。


请问您如何通过Synaptic Package Manager、Software Center或yum安装python-dev?我不是root用户,也不能使用sudo。我必须在我的本地目录中安装它。任何帮助将不胜感激。 - runner frank

4

在CentOS上,python开发库的名称为python-devel,而不是python-dev。

使用sudo yum install python-devel 在您的CentOS系统上安装它们。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接