Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
673 views
in Technique[技术] by (71.8m points)

anaconda - New conda environment is created without python

The conda documentation says that when you use

conda create --name myenv

The new environment

uses the same version of Python that you are currently using because you did not specify a version.

However, that's not the case for me. I have Windows 10 and Anaconda. I am into the "base" environment created by default.

If I run

conda create --name testenv

Then when I activate the environment

conda activate testenv

There is no Python. If I write

python

to the console the Microsoft Store is opened.

To have a Python interpreter I need to manually specify it

conda create --name testenv2 python=3.8
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That specific note in the Conda documentation was a hold-over from before Conda v4.4 and has since been corrected (see here and here).

Background

Previous to Conda v4.4, the base environment's bin/ directory was always on the PATH, hence why not installing a Python interpreter in a new environment it would fall back to the base Python. Conda v4.4 introduced a new strategy for managing environment isolation via defining the primary interface to Conda as a set of shell functions and allowing the base bin directory only to be included on PATH when the base environment was active. This strategy provides cleaner isolation of environments, which means that only what is in the active environment will be available.

Hence, if you want Python in the environment, it must be explicitly installed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...