添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
欢快的冰棍  ·  centos ...·  11 月前    · 
发怒的卤蛋  ·  db2 大于等于-掘金·  1 年前    · 
力能扛鼎的乌龙茶  ·  docker-compose ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am encountring the following issue. When creating a brand new environment in conda and installing pip , the default version of python3 is switched from 3.7 to 3.8 . Why is this and how can I avoid this? The exact steps are below.

Thank you

conda create -n myenv
conda activate myenv
# python3 --> python3.7.4
conda install pip
# python3 --> python3.8.2
# pip -V --> pip 20.0.2 from /mypath/conda/miniconda3/envs/myenv/lib/python3.8/site-packages/pip (python 3.8)

You never installed python explicitly into your new env, so what you see after conda activate myenv is still the same python from your base env. Now when you do conda install pip, conda recognizes that python is a requirement of pip and therefore downloads and installs python (also check the output of the conda install pip call, where it will list python under the The following NEW packages will be INSTALLED). Since it has no further info, it just grabs the latest one. So your python version is never actually changed, there just never was a python in your venv when you created it.

To fix, explicitly install python into your environment with required version when creating it:

conda create -n myenv python=3.7
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.