简体   繁体   English

使用不同的python版本创建conda环境时,python版本不会改变

[英]Python version does not change when creating conda environment with different python version

I currently have python3 set as my default python version but I'd like to be able to switch back to python2 for certain things so I created a conda environment with the following command:我目前将 python3 设置为我的默认 python 版本,但我希望能够为某些事情切换回 python2,所以我使用以下命令创建了一个 conda 环境:

conda create -n py2 python=2.7

and then activated it with:然后使用以下命令激活它:

source activate py2

but when I do:但是当我这样做时:

python --version

I still get我仍然得到

Python 3.6.8蟒蛇 3.6.8

What am I doing wrong here?我在这里做错了什么? I'm trying to download a conda package this is only python2 compatible but despite being in a python2 environment, it keeps telling me my python version is incompatible.我正在尝试下载一个仅与 python2 兼容的 conda 包,但尽管在 python2 环境中,它一直告诉我我的 python 版本不兼容。

You might be running into the issue where you have multiple environments on top of one another.您可能会遇到多个环境相互叠加的问题。

Try running:尝试运行:

conda deactivate

multiple times in order to exit from all of the environments.多次以退出所有环境。 Then run:然后运行:

condo activate py2

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

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