如何在python 3.6而非默认的python 2.7上安装pip? [英] How to install pip on python 3.6, not the default python 2.7?
问题描述
所以整天,我一直在尝试安装pip.我执行了curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
.然后sudo python get-pip.py
.接下来,我用sudo pip install numpy
安装numpy.最后,我打开了python 3.6 IDLE,然后尝试import numpy as np
并收到一条错误消息,指出该模块不存在.
So all day, I have been trying to install pip. I've executed curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
. Then sudo python get-pip.py
. Next I went to install numpy with sudo pip install numpy
. Finally, I opened up the python 3.6 IDLE and I tried to import numpy as np
and got an error saying that the module didn't exist.
我发现pip已安装在/Library/Python/2.7/site-packages
中,因此我从目录中删除了2.7.我再次重做整个过程,并得到了相同的错误:|
I found out that the pip was installed in /Library/Python/2.7/site-packages
so I deleted 2.7 from the directory. I redid the whole process again and got the same error :|
我想知道是否需要更改默认的python
是不明智的.我该怎么办?我确定我已经删除了所有带有python 2.7的内容吗?
I'm wondering if I need to change the default python
which I've been told is not wise. What do I do? I' sure I've deleted everything with python 2.7 in it?
MacBookAir OSX-Sierra
MacBookAir OSX - Sierra
或者还有另外一种方法可以在python 3.6中安装numpy吗???
Or is there an alternate way that I can install numpy in python 3.6????
推荐答案
您不应删除系统python.删除/Library/Python
或其子文件夹中的任何内容.
You shouldn't delete the system python. Delete nothing in /Library/Python
or it's subfolders.
您是如何安装python 3.6的?通常,它将以python3.6
的形式安装,并带有指向python3
的符号链接. pip3
通常随它一起安装.
How did you install python 3.6? Usually, it'll be installed as python3.6
with a symlink to python3
. pip3
is usually installed with it.
所以您可能想做的是:
pip3 install numpy
python3
>>> import numpy
这篇关于如何在python 3.6而非默认的python 2.7上安装pip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!