問題描述
我創建了一個 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 environment, I get the following warning message when starting Python in the virtual environment:
(env3.7.3) C:Users
edexOneDriveDocumentsEducationMachine Learning-Ng PythonExercise7>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 environment, not the base Conda environment. 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.
推薦答案
錯誤信息告訴你找到了來自Conda環境的Python解釋器,但是conda activate
沒有被調用.你把conda環境的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 environment into the Windows search path? That would be wrong.
您說的是 virtualenvs.但是 Python 虛擬環境不同于 Conda 環境.也許你混淆了這兩個概念?
You're talking about virtualenvs. 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.
這篇關于Python在Conda環境中,但在Windows虛擬環境中沒有激活的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!