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

标签 numpy python-3.x

对于 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/

相关文章:

python - (Python 3.3)无法弄清楚为什么当值达到 5 时函数会创建无限循环

python - : import scipy as sp/sc 的官方缩写

python - 如何在 numpy 的日期中模糊添加年份?

python - pandas 时间戳和包含 timedelta 值的数组的总和

python - django admin 排序外键字段列表

python - matplotlib 路径线宽连接到图形缩放

python - 有什么建议可以比当前方法更快地生成 newlist.append(q) 列表吗?

python - A[0] 和 A[0 :1] numpy arrays in python 之间的区别

python - 返回方法的 pytests 固定装置的类型提示

python - 将列表列表与集合列表进行比较的最快方法