gpt4 book ai didi

numpy - 在 python3.3 上安装 numpy - 为 python3 安装 pip

转载 作者:行者123 更新时间:2023-12-02 03:55:17 27 4
gpt4 key购买 nike

对于 python 3.2,我使用了 sudo apt-get install python3.2-numpy。它有效。python3.3怎么办?我想不出任何办法。 scipy 等也是如此。谢谢。

编辑:这就是它的样子

radu@sunlit-inspired:~$ python3
Python 3.3.2 (default, Jul 3 2013, 10:17:40)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'

最佳答案

在下面的解决方案中,我使用 python3.4 作为二进制文件,但它可以安全地与任何版本或二进制文件一起使用。它在 Windows 上也能正常工作(显然,除了使用 wget 下载“get-pip.py”,但只需将文件保存在本地并使用 python 运行,见下文)。

如果您安装了多个版本的 python,这非常有用,因此您可以管理每个 python 版本的外部库。

所以首先,我推荐 get-pip.py,安装 pip 非常棒:

wget https://bootstrap.pypa.io/get-pip.py

然后你需要为你的Python版本安装pip,我有python3.4所以对我来说这是命令:

python3.4 get-pip.py

现在 pip 已为此版本安装,我将以这种方式使用 pip“上下文化”到该版本:

python3.4 -m pip

因此,要为 python3.4 安装 numpy,我将使用:

python3.4 -m pip install numpy

请注意,numpy 是一个相当繁重的库。我以为我的系统挂起并出现故障。但是使用 verbose 选项,您可以看到系统很好:

python3.4 -m pip install numpy -v

This may tell you that you lack python.h but you can easily get python headers:

Of course you want to keep using your python version in those commands

On Debian-like (Debian, Ubuntu, Kali, ...) :

apt-get install python34-dev

On RHEL (Red hat, CentOS, Fedora) it would be something like this:

yum install python34-devel

or more recently

dnf install python34-devel

If that doesn't work for you, there's a great topic with more coverage: fatal error: Python.h: No such file or directory

Finally, once you've got python header files you can just rerun the pip install command:

python3.4 -m pip install numpy -v

关于numpy - 在 python3.3 上安装 numpy - 为 python3 安装 pip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17443354/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com