适用于anaconda环境的pip版本错误.使用"conda activate"激活环境时,我该怎么做才能更正点子版本? [英] Wrong pip version for anaconda's environments. What should I do to correct the pip version when activate a env using `conda activate`?

查看:141
本文介绍了适用于anaconda环境的pip版本错误.使用"conda activate"激活环境时,我该怎么做才能更正点子版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的蟒蛇中有4个环境,如下所示.

I have 4 envs in my anaconda as listed below.

>>> conda info --envs
base                     /home/gph/anaconda3
py36_torch0.4         *  /home/gph/anaconda3/envs/py36_torch0.4
py37_torch1.1            /home/gph/anaconda3/envs/py37_torch1.1
python3.6                /home/gph/anaconda3/envs/python3.6

在py36_torch0.4和py37_torch1.1中,我都做了一些测试.

In both py36_torch0.4 and py37_torch1.1, I did some test.

>>>(py36_torch0.4) gph@gph-1050Ti:~ $ whereis pip
pip: /home/gph/.local/bin/pip3.5 
/home/gph/.local/bin/pip 
/home/gph/anaconda3/envs/py36_torch0.4/bin/pip3.6 
/home/gph/anaconda3/envs/py36_torch0.4/bin/pip

(py36_torch0.4) gph@gph-1050Ti:~ $ pip -V
pip 19.1.1 from /home/gph/.local/lib/python3.5/site-packages/pip (python 3.5)

(py37_torch1.1) gph@gph-1050Ti:~ $ whereis pip
pip: /home/gph/.local/bin/pip3.5 
/home/gph/.local/bin/pip 
/home/gph/anaconda3/envs/py37_torch1.1/bin/pip

(py37_torch1.1) gph@gph-1050Ti:~ $ pip -V
pip 19.1.1 from /home/gph/.local/lib/python3.5/site-packages/pip (python 3.5)

我们可以看到对于每个env_name,我们都有envs/env_name/bin/pip,但是pip -V的输出始终是/home/gph/.local/lib/python3.5/site-packages/pip (python 3.5).
怎么了?激活特定的环境后,我应该怎么做才能正确设置点子版本?

We can see that for each env_name we have envs/env_name/bin/pip, but the output of pip -V is always /home/gph/.local/lib/python3.5/site-packages/pip (python 3.5).
What is wrong? What should I do to make the pip version right when activate a specific env?

我尝试按照此问题中的说明取消设置PYTHONPATH: conda env中的错误点数.但这没用.

I have tried unset PYTHONPATH as told in this question: Wrong pip in conda env. But it is no use.

推荐答案

您已经在conda环境之外直接将pip安装到了主目录中.这优先于conda中安装的所有内容.

You've installed pip outside of the conda environments, directly into your home directory. This takes precedence over everything that's installed in conda.

如果您希望从隔离的conda环境中受益,则不能在用户级别安装软件包.这将摆脱所有这些(但也许还有更多):

If you want to benefit from isolation of conda environments, you cannot install packages on the user level. This will get rid of all of them (but maybe also some more):

rm -rf /home/gph/.local

在实际删除/home/gph/.local之前,您可能想看看它还安装了什么.

You might want to have a look at what else is installed in /home/gph/.local before actually removing it.

这篇关于适用于anaconda环境的pip版本错误.使用"conda activate"激活环境时,我该怎么做才能更正点子版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆