简体   繁体   English

适用于anaconda环境的错误点子版本。 使用“ 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`?

I have 4 envs in my anaconda as listed below. 我的蟒蛇中有4个环境,如下所示。

>>> 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

In both py36_torch0.4 and py37_torch1.1, I did some test. 在py36_torch0.4和py37_torch1.1中,我都做了一些测试。

>>>(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)

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) . 我们可以看到,对于每个env_name我们都有envs/env_name/bin/pip ,但是pip -V的输出始终是/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? 激活特定的环境时,应该怎么做才能正确设置pip版本?

I have tried unset PYTHONPATH as told in this question: Wrong pip in conda env . 我已经尝试过按此问题中的说明设置未设置的PYTHONPATH: conda env中的错误点 But it is no use. 但这没有用。

You've installed pip outside of the conda environments, directly into your home directory. 您已经在conda环境外部安装了pip ,直接将其安装到主目录中。 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. 如果要从隔离的conda环境中受益,则不能在用户级别安装软件包。 This will get rid of all of them (but maybe also some more): 这将摆脱所有这些(但也许还有更多):

rm -rf /home/gph/.local

You might want to have a look at what else is installed in /home/gph/.local before actually removing it. 在实际删除之前,您可能需要查看/home/gph/.local还安装了什么。

Use pip as a module called by the Python interpreter of your env. 将pip用作环境的Python解释器调用的模块。

python -m pip install some_package where python is the one active on your env, for example /home/gph/anaconda3/envs/python3.6/bin/python . python -m pip install some_package ,其中python是您的环境中活跃的一个,例如/home/gph/anaconda3/envs/python3.6/bin/python

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM