本文介绍了在python3.3上安装numpy-为python3安装pip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于python 3.2,我使用了sudo apt-get install python3.2-numpy.为python3.3做什么?我没有想到的作品. scipy等也是如此.谢谢.

For python 3.2 I used sudo apt-get install python3.2-numpy.It worked.What to do for python3.3? Nothing I could think of works. Same goes for scipy, etc.Thanks.

这是它的样子

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用作二进制文件,但是可以安全地与任何版本或python二进制文件一起使用.它也可以在Windows上正常工作(显然,除了使用wget下载pip之外,只是将文件保存在本地并使用python运行).

In the solution below I used python3.4 as binary, but it's safe to use with any version or binary of python. it works fine on windows too (except the downloading pip with wget obviously but just save the file locally and run it with python).

如果您安装了多个版本的python,那就太好了,因此您可以管理每个python版本的外部库.

This is great if you have multiple versions of python installed, so you can manage external libraries per python version.

所以首先,我建议get-pip.py,安装pip很棒:

So first, I'd recommend get-pip.py, it's great to install pip :

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

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

Then you need to install pip for your version of python, I have python3.4 so for me this is the command :

python3.4 get-pip.py

现在为python3.4安装了pip,为了获得python3.4的库,需要在此版本中调用它,如下所示:

Now pip is installed for python3.4 and in order to get libraries for python3.4 one need to call it within this version, like this :

python3.4 -m pip

因此,如果要安装numpy,请使用:

So if you want to install numpy you would use :

python3.4 -m pip install numpy

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

Note that numpy is quite the heavy library. I thought my system was hanging and failing.But using the verbose option, you can see that the system is fine :

python3.4 -m pip install numpy -v

在RHEL(Red Hat,CentOS,Fedora)上,会是这样的:

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

yum install python34-devel

在类似debian(Debian,Ubuntu,Kali等)上:

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

apt-get install python34-dev

然后重新运行:

python3.4 -m pip install numpy -v

这篇关于在python3.3上安装numpy-为python3安装pip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:43