Python位于conda env中,但尚未在Windows虚拟环境中激活
我创建了Windows(10)Python虚拟环境(env3.7.3).当我打开在虚拟环境中激活的cmd窗口时,在虚拟环境中启动Python时会收到以下警告消息:
I created a Windows (10) Python virtual environment (env3.7.3). When I open a cmd window activated in the virtual env, I get the following warning message when starting Python in the virtual env:
(env3.7.3) C:\Users\redex\OneDrive\Documents\Education\Machine Learning-Ng Python\Exercise7>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
此警告以前曾在其他环境中发布过,但没有解决我的问题.此警告仅出现在python虚拟环境中,而不出现在基本conda环境中.这似乎是Windows或Anaconda环境变量的问题,但我所知不多! Anaconda最近进行了升级,以前似乎还不错,所以可能存在错误或设置问题.
This warning has been posted before in a different context but it did not address my question. This warning appears only in the python virtual env, not the base conda env. This seems like a windows or anaconda environment variable issue but I don't know enough to know! Anaconda was recently upgraded and it seemed fine before, so there may be a bug or setting issue.
在此问题上的任何指导或专业知识将不胜感激.
Any guidance or expertise on this matter would be much appreciated.
错误消息告诉您,已找到conda环境中的Python解释器,但尚未调用conda activate <envname>
.您是否将conda env的bin/
目录放入Windows搜索路径?那是错误的.
The error message tells you that the Python interpreter from the conda environment was found, but that conda activate <envname>
has not been called. Did you put the bin/
directory of the conda env into the Windows search path? That would be wrong.
您正在谈论虚拟环境.但是Python虚拟环境不是conda环境.也许您混淆了这两个概念?
You're talking about virtual envs. But Python virtual environments are something else than conda environments. Maybe you mixed up the two concepts?
conda基础环境中的Python解释器不会抱怨缺少激活,因为它是由某些conda
子命令调用的,并且可以在没有激活环境的情况下工作.但是,在该conda环境中工作时也应该调用conda activate base
.
The Python interpreter from the conda base environment does not complain about missing activation, because it's called by some of the conda
subcommands and can work without an activated environment. Nevertheless, you should call conda activate base
when working with that conda environment, too.