Python在Conda环境中,但在Windows虚拟环境中没有激

时间:2023-03-02
本文介绍了Python在Conda环境中,但在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 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模板网!

上一篇:Conda - 离线安装/更新 下一篇:如何在 Anaconda 中恢复到以前的包?

相关文章

最新文章