[英]Why pip3 install in python2 sitepackages
First I use首先我使用
Python 3.6.5
Python 2.7.14
and mac.
In my case, I just download module like numpy
(for example, and other's same) when i use pip3
it said like..就我而言,当我使用
pip3
时,我只下载像numpy
这样的模块(例如,和其他模块一样),它说像..
and pip is same.和 pip 是一样的。
but when I use it, in python3
但是当我使用它时,在
python3
In python2
, It working well...在
python2
,它运行良好......
How can I fix it?我该如何解决?
It seems that pip3
refers to Python-2.7's pip module or any other version of Python-3 that you have installed on your machine. pip3
似乎是指 Python-2.7 的 pip 模块或您机器上安装的任何其他版本的 Python-3。 However, you can install packages directly using the intended Python version.但是,您可以使用预期的 Python 版本直接安装包。 You'd need to just use
-m
option.你只需要使用
-m
选项。
python3.6 -m pip install numpy
Another option is to changing the source path that pip3
refers to.另一种选择是更改
pip3
引用的源路径。 You can do this by finding the path of Python-3.6's pip and just bind it to pip3
alias.您可以通过找到 Python-3.6 的 pip 的路径并将其绑定到
pip3
别名来pip3
。
Find the absolute path of the python3
interpreter with a command like this:使用如下命令查找
python3
解释器的绝对路径:
$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python
Your path may be something different, of course.当然,您的路径可能有所不同。 Copy that line to your clipboard.
将该行复制到剪贴板。
Edit the pip3
script, which was installed using incorrect interpreter.编辑使用错误解释器安装的
pip3
脚本。 Something like this:像这样的东西:
vi $(which pip3)
You might need to use sudo
here, but try it first without.您可能需要在此处使用
sudo
,但请先尝试不使用。 The first line will be something like:第一行将类似于:
#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Change it to the path found in the previous step, eg将其更改为上一步中找到的路径,例如
#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python
Save the pip3
file and exit.保存
pip3
文件并退出。 This should be sufficient to associate pip3
with the correct environment.这应该足以将
pip3
与正确的环境相关联。 Check and verify the result with pip3 --version
.使用
pip3 --version
检查并验证结果。 Now pip3 install numpy
should work as expected.现在
pip3 install numpy
应该按预期工作。
这对我有用:
python3 -m pip install -U --force-reinstall pip
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.