[英]why pip install module in /usr/local/lib/python3.4/dist-packages
I want to install easydict
module for python2.7 and I use the following command:我想为 python2.7 安装easydict
模块,我使用以下命令:
sudo pip install easydict
and I find the easydict module is installed in the python3 dir:我发现easydict模块安装在python3目录中:
Downloading/unpacking easydict
Downloading easydict-1.6.zip
Running setup.py (path:/tmp/pip-build-hdy25apc/easydict/setup.py) egg_info for package easydict
Installing collected packages: easydict
Running setup.py install for easydict
Could not find .egg-info directory in install record for easydict
Successfully installed easydict
Cleaning up...
sudo pip install easydict
Requirement already satisfied (use --upgrade to upgrade): easydict in /usr/local/lib/python3.4/dist-packages
Cleaning up...
Why does this happen?为什么会发生这种情况? Thank you very much.非常感谢。
It depends on your system path.这取决于您的系统路径。 If system path has path of pip binary or python binary of 3.x prior to the path of 2.x versions.如果系统路径在 2.x 版本的路径之前具有 3.x 的 pip 二进制文件或 python 二进制文件的路径。 Then 3.x takes preference over 2.x然后 3.x 优先于 2.x
Please re-arrange your system path to have 2.x paths before 3.x paths请重新安排您的系统路径,使其在 3.x 路径之前具有 2.x 路径
Your pip is pointing to python3, To change the pip pointing to python2 do the following您的 pip 指向 python3,要更改指向 python2 的 pip,请执行以下操作
First remove python pip首先删除python pip
sudo apt-get remove python-pip
make python3 to point python 2.7使 python3 指向 python 2.7
alias python3=python
now if you type python3 in terminal you can see python 2.7 showing up现在如果你在终端中输入 python3 你可以看到 python 2.7 出现
Then install python-pip然后安装python-pip
sudo apt-get install python-pip
If you type pip you can see pip pointing to python 2.7如果你输入 pip 你可以看到 pip 指向 python 2.7
now point python3 to python3现在将 python3 指向 python3
alias python3=python3
Because you are using the pip3, you can use which find where is the pip因为你用的是pip3,所以可以用which find pip在哪里
#which pip
/usr/local/bin/pip
maybe you can find the pip2 or pip2.7 in the same dir也许你可以在同一个目录中找到 pip2 或 pip2.7
#pip2 -V
pip 20.2.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
so you should use pip2 to install module所以你应该使用 pip2 来安装模块
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.