如何在 python 3.6 上安装 pip,而不是默认的 python 2.7?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41317248/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install pip on python 3.6, not the default python 2.7?
提问by Fizics
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。我已经执行了curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
。然后sudo python get-pip.py
。接下来我去安装 numpy sudo pip install numpy
。最后,我打开了 python 3.6 IDLE 并尝试打开import numpy as np
并收到错误消息,说该模块不存在。
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 :|
我发现安装了 pip,/Library/Python/2.7/site-packages
所以我从目录中删除了 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?
我想知道我是否需要更改默认设置python
,我被告知这是不明智的。我该怎么办?我确定我已经删除了包含 python 2.7 的所有内容?
MacBookAir OSX - Sierra
MacBookAir OSX - Sierra
Or is there an alternate way that I can install numpy in python 3.6????
或者有没有另一种方法可以在python 3.6中安装numpy????
回答by Josh Smeaton
You shouldn't delete the system python. Delete nothing in /Library/Python
or it's subfolders.
你不应该删除系统python。删除任何内容/Library/Python
或其子文件夹。
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.
你是如何安装python 3.6的?通常,它会通过python3.6
符号链接安装到python3
. pip3
通常与它一起安装。
So what you probably wanted to do was:
所以你可能想做的是:
pip3 install numpy
python3
>>> import numpy