简体   繁体   English

为什么我在创建新的 conda 环境时必须指定 python 版本?

[英]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.

相关问题 克隆基础conda环境时指定Python版本 - Specify Python version when cloning base conda environment 我是否需要在 conda 基础环境中更新/升级 Python 版本? - Do I need to update/upgrade Python version at conda base environment? 当我安装了多个 python 版本时,如何为 VSCode 虚拟环境指定 python 版本? - How to specify the python version for VSCode virtual environment, when I have multiple python versions intalled? 在 Mac 上使用 python 3.5 在 conda 中创建新环境 - Creating a new environment in conda with python 3.5 on Mac 创建新的Conda环境时出现PackageNotFoundError - PackageNotFoundError when creating new Conda environment 使用不同的python版本创建conda环境时,python版本不会改变 - Python version does not change when creating conda environment with different python version 即使我已激活本地virtualenv环境,新软件包也将以系统级python版本安装。 - New Packages are being installed in system wide python version even when I have activated the local virtualenv environment 为什么当我使用conda安装环境时却没有提供最新版本 - Why when I install a environment with conda it does not give me the latest version 为什么conda切换环境后python版本没有切换? - Why did the python version not switch after conda switched the environment? 为什么Conda在激活环境后无法调用正确的Python版本? - Why Conda cannot call correct Python version after activating the environment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM