当尝试安装numpy时,easy_install和pip出现错误

3
我在我的机器上运行Python 2.7.2。我试图使用easy_install和pip安装numpy,但它们都无法安装成功。所以当我尝试输入以下命令时: sudo easy_install-2.7 numpy 我会收到如下错误提示: "The package setup script has attempted to modify files on your system that are not within the EasyInstall build area, and has been aborted. This package cannot be safely installed by EasyInstall, and may not support alternate installation locations even if you run its setup script by hand. Please inform the package's author and the EasyInstall maintainers to find out if a fix or workaround is available." 另外,当我使用pip时: sudo pip-2.7 install numpy 我会收到如下错误提示: RuntimeError: Broken toolchain: cannot link a simple C program 有没有什么解决方法?
2个回答

6

在安装Django项目的依赖时,我遇到了同样的错误。以下方法适用于我:

通过pip install --upgrade setuptools升级你的setuptools版本,并再次运行安装包的命令。


在我的MacOS上這有效。 - Isma Rekathakusuma

2

您需要一个编译器和开发工具,以及Python的头文件。

您没有提到您的操作系统。

在我的系统(Ubuntu)上,我可以通过以下命令安装python-dev和工具链依赖项:

$ sudo apt-get install python-dev

那我可以翻译为:"那么我就可以使用pip安装numpy了。"

请详细说明一下,如果我只是解决这个问题,能否保留我的Python版本?有可能吗? - khan
请通过您的软件包管理器或其他方式安装Python开发人员工具。 - Corey Goldberg
我在我的Red Hat 4.1.2-51操作系统上运行两个版本(2.4和2.7)。我使用yum安装了python-devel,那个错误已经消失了。然而,我仍然无法'easy_install-2.7 numpy',因为现在它给出了这个错误:SystemError: Cannot compile 'Python.h'。也许你需要安装python-dev|python-devel。我还使用yum安装了python-numpy并安装了python-numpy。但是,我仍然无法在python分发中安装numpy。有任何想法吗? - khan
听起来你缺少Python-2.7头文件。 - Corey Goldberg

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