[英]Why do I have to specify the python version when creating a new conda environment?
I do conda create --name env
then conda activate env
.我做
conda create --name env
然后conda activate env
。
My prompt now has (env)
at the beginning of it.我的提示现在有
(env)
在它的开头。 Then I try running python
at the prompt and it returns然后我尝试在提示符下运行
python
并返回
'python' is not recognized as an internal or external command, operable program or batch file.
The documentation explicitly states 文档明确指出
This environment uses the same version of Python that you are currently using because you did not specify a version.
此环境使用的 Python 版本与您当前使用的 Python 版本相同,因为您未指定版本。
However, if I do conda create --name env python=3.8
, my environment correctly runs python 3.8.但是,如果我执行
conda create --name env python=3.8
,我的环境将正确运行 python 3.8。 It seems like if I don't specify a version, my environment is completely empty (which it is when I look in the directory).好像如果我不指定版本,我的环境是完全空的(当我查看目录时就是这样)。 But the documentation says that it should have the version of python from the base.
但是文档说它应该有基础的python版本。 What am I doing wrong?
我究竟做错了什么?
I'm using an anaconda prompt in Windows 10.我在 Windows 10 中使用 anaconda 提示符。
I think that bit of documentation is outdated and is a hold-over from pre-v4.4, when the recommended practice was to put the base env's bin/
directory on PATH
.我认为那部分文档已经过时并且是 v4.4 之前的保留,当时推荐的做法是将基础env 的
bin/
目录放在PATH
。 In Conda v4.4+, the base env is no longer accessible by default when another env is activated.在 Conda v4.4+ 中,当激活另一个 env 时,默认情况下无法再访问基础env。
To have Python in an env, one must explicitly request it to be installed, eg,要在 env 中使用 Python,必须明确要求安装它,例如,
conda create --name env python
Note, one doesn't have to specify a version.请注意,不必指定版本。
In the end, this should be seen as an advantage, since it allows users to create non-Python envs and keeps the base env isolated.最后,这应该被视为一个优势,因为它允许用户创建非 Python 环境并保持基本环境隔离。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.