问题
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
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.
回答1:
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.
You're talking about virtual envs. But Python virtual environments are something else than conda environments. Maybe you mixed up the two concepts?
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.
来源:https://stackoverflow.com/questions/56679132/python-is-in-conda-env-but-has-not-been-activated-in-windows-virtual-env