Python 为什么 '(base)' 出现在我的 anaconda 命令提示符中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51526503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:52:17  来源:igfitidea点击:

Why does '(base)' appear in my anaconda command prompt?

pythonanacondavirtualenv

提问by vineeth venugopal

My anaconda command prompt now says:

我的 anaconda 命令提示符现在显示:

(base) C:\users\user_name>

I would like to know why (base) appears in front of the prompt. This started appearing since I created a virtual environment to run Django. If I enter 'deactivate' the prompt disappears but if I close the terminal and open a new terminal the 'base' is back again.

我想知道为什么(base)出现在提示前。这是因为我创建了一个虚拟环境来运行 Django。如果我输入“deactivate”,提示消失,但如果我关闭终端并打开一个新终端,“base”又回来了。

(base) C:\users\user_name> deactivate
C:\users\user_name>

The trouble is that this prompt does not recognize pip or any anaconda commands. I can run pip on the 'base' prompt, but not on the original one. I installed a module in '(base)...' using pip but this module is recognized by my ide.

问题是这个提示无法识别 pip 或任何 anaconda 命令。我可以在 'base' 提示符下运行 pip,但不能在原始提示符下运行。我使用 pip 在 '(base)...' 中安装了一个模块,但我的 ide 可以识别该模块。

conda list anaconda

in '(base)..' gives th version of Anaconda as 4.4. without the base, it does not recognize conda. I have run pip and conda several times before this happened. I'm running Windows 10.

在 '(base)..' 中给出的 Anaconda 版本为 4.4。没有基础,它就无法识别 conda。在发生这种情况之前,我已经多次运行 pip 和 conda。我正在运行 Windows 10。

回答by Woko

Try this:

尝试这个:

conda config --set auto_activate_base false

The changeps1only hide the command prompt, you still in this environment.

changeps1只隐藏的命令提示符下,你仍然在这个环境。

auto_activate_basecan avoid entering the environment.

auto_activate_base可以避免进入环境。

回答by B Seven

Although Blockchain Business's answer is correct, as of v 4.6.4

尽管 Blockchain Business 的答案是正确的,但截至 v 4.6.4

DeprecationWarning: 'source deactivate' is deprecated. Use 'conda deactivate'.

so,

所以,

conda deactivate

This actually deactivates Anaconda completely, so may not be the best solution...

这实际上完全停用了 Anaconda,所以可能不是最好的解决方案......

To restore:

恢复:

 conda activate

回答by Wasim

If you face the issue in Ubuntu you can try the below two steps to remove it from your command prompt.

如果您在 Ubuntu 中遇到此问题,您可以尝试以下两个步骤将其从命令提示符中删除。

  1. conda config
  2. conda config --set changeps1 False
  1. conda config
  2. conda config --set changeps1 False

回答by Blockchain Business

I had the same issue, I typed the following command to remove the (base) reference:

我遇到了同样的问题,我输入了以下命令来删除(基本)引用:

source deactivate

源停用

回答by Peter

Showing the active environment in front of the path like (base) C:\users\user_name>is a feature, not a bug. If you pip-install a module into the base environment (bad practice warning: Use conda install this_module -c conda-forgeor pip install this_moduleinto a separate environment), you'll first need to activate the base environment before you can actually use this_module. If you don't know how to do this in your IDE (although this a base functionallity of any IDE), open a cmd shell, type conda activateand then start your IDE directly from the (base) C:\users\user_name>prompt.

在路径前面显示活动环境(base) C:\users\user_name>一项功能,而不是错误。如果您将模块 pip 安装到基础环境中(错误做法警告:使用conda install this_module -c conda-forgepip install this_module进入单独的环境),您首先需要激活基础环境,然后才能实际使用this_module。如果您不知道如何在 IDE 中执行此操作(尽管这是任何 IDE 的基本功能),请打开 cmd shell,键入conda activate然后直接从(base) C:\users\user_name>提示符启动您的 IDE 。

回答by zalloy

It sounds like when you installed Anaconda, it's now seeing that as your default environment, and with Anaconda it's best that you install packages using condarather than by using pip, because at best pip installed packages won't be recognized by Anaconda, and at worst the pip installed packages can break your Anaconda install. I went through some of this before myself, as I needed to use Anaconda for a Python course I was taking, however I use Kubuntu, so I don't have a lot of knowledge around using it on Windows.

听起来像当您安装 Anaconda 时,它现在将其视为您的默认环境,而对于 Anaconda,您最好使用conda而不是使用来安装软件包pip,因为 pip 安装的软件包充其量不会被 Anaconda 识别,最坏的情况是pip 安装的软件包可能会破坏您的 Anaconda 安装。我在自己之前经历了一些这样的事情,因为我需要在我正在学习的 Python 课程中使用 Anaconda,但是我使用的是 Kubuntu,所以我没有很多关于在 Windows 上使用它的知识。

For more info on using Anaconda, see https://conda.io/docs/user-guide/getting-started.htmlYou can probably use Anaconda Navigator to create virtual environments and install packages too.

有关使用 Anaconda 的更多信息,请参阅https://conda.io/docs/user-guide/getting-started.html您也可以使用 Anaconda Navigator 创建虚拟环境并安装软件包。