康达激活不起作用?

Abh*_*tia 37 anaconda conda

 gonzo ? ~/a/packages ? conda env list
# conda environments:
#
ppo_latest               /nohome/jaan/abhishek/anaconda3/envs/ppo_latest
root                  *  /nohome/jaan/abhishek/anaconda3

 gonzo ? ~/a/packages ? conda activate ppo_latest
 gonzo ? ~/a/packages ? which python                                                                                     (ppo_latest)
/nohome/jaan/abhishek/anaconda3/bin/python
 gonzo ? ~/a/packages ? conda deactivate                                                                                 (ppo_latest)
 gonzo ? ~/a/packages ? which python
/nohome/jaan/abhishek/anaconda3/bin/python
Run Code Online (Sandbox Code Playgroud)

环境被激活而没有错误.然后我们检查它指的是哪个python.它不会改变,为什么?

dar*_*ith 43

截至conda 4.4,命令

conda activate <envname>
Run Code Online (Sandbox Code Playgroud)

在所有平台上都是一样的.该程序添加condaPATH非Windows平台的环境变量(在Windows上,你应该使用蟒蛇提示),以及在环境激活程序的变化,是在详细版本说明了畅达4.4.0.


对于4.4以上的conda版本,命令是

source activate <envname>
Run Code Online (Sandbox Code Playgroud)

在Linux和macOS或

activate <envname>
Run Code Online (Sandbox Code Playgroud)

在Windows上.你需要删除conda.

  • 我在收到CommandNotFoundError后发现了这个问题:您的外壳尚未正确配置为在Windows上使用“ conda activate”。解决方法是使用`activate ...`而不是`conda activate ...` (7认同)
  • 不能用鱼来源. (3认同)
  • 另外,根据这篇文章,“source”是正确的命令:https://superuser.com/a/84624/229278 您可能需要安装一些额外的依赖项:https://superuser.com/a/1235985/229278 (2认同)

小智 31

anaconda 函数默认不导出,可以使用以下命令完成:

source ~/anaconda3/etc/profile.d/conda.sh

conda activate my_env
Run Code Online (Sandbox Code Playgroud)


Jor*_*mba 29

我刚刚遇到了类似的问题。最近开始在 windows 上开发,所以习惯了 PowerShell。具有讽刺意味的是,当我尝试在 Git-bash 中使用 'conda activate' 时出现错误

$ conda activate obf

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - cmd.exe
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'. 
Run Code Online (Sandbox Code Playgroud)

按照指示在我的 PowerShell(提升)中运行该命令对我来说很有效。

conda init powershell 
Run Code Online (Sandbox Code Playgroud)

这应该适用于所有终端环境,只是奇怪的 PowerShell 本身没有返回此错误。

  • 哇!尝试了 1000 种方法,但你的建议终于奏效了。我只需使用 CALL conda.bat activate &lt;my conda env name&gt; 启动我的bat文件。 (2认同)
  • 在我的cmd中执行`conda init`后,conda activate工作了,谢谢答案 (2认同)

小智 25

默认情况下,函数不会导出以在子 shell 中可用。我建议你这样做:

source ~/anaconda3/etc/profile.d/conda.sh
conda activate my_env
Run Code Online (Sandbox Code Playgroud)

在上面的命令中,将 ~/anaconda3/ 替换为 miniconda / anaconda 安装的路径。


kar*_*rbi 18

从 conda 4.10.1 开始,以下是我在 Windows 上使用 Sublime text 3 中的 Git Bash 终端(cmd 和 Git cmd 相同)的方法:

$ source activate env_name
Run Code Online (Sandbox Code Playgroud)

对我来说:$ activate env_name没有$ conda activate env_name用!

检查激活的 conda 环境列表,在我的例子中我使用

$ conda env list
Run Code Online (Sandbox Code Playgroud)

或者

$ conda info --envs
Run Code Online (Sandbox Code Playgroud)

激活的环境前面有 *

请注意,我已经将 anaconda 添加到我的路径中。


小智 17

  • conda init在cmd中运行
  • 重新启动命令
  • 跑步conda activate envName


小智 16

To use "conda activate" via Windows CMD, not the Anaconda Prompt:
(in response to okorng's question, although using the Anaconda Prompt is the preferred option)

First, we need to add the activate.bat script to your path:
Via CMD:

set PATH=%PATH%;<your_path_to_anaconda_installation>\Scripts
Run Code Online (Sandbox Code Playgroud)

Or via Control Panel, open "User Accounts" and choose "Change my environment variables".

Then calling directly from Windows CMD:

activate <environment_name>
Run Code Online (Sandbox Code Playgroud)

without using the prefix "conda".

(Tested on Windows 7 Enterprise with Anaconda3-5.2.0)


Ale*_*ber 11

(base)如果运行后控制台未显示conda activate base,请尝试运行:

conda init

然后运行应该在 shell 提示符的开头conda activate <your_env>显示 的名称。(<your_env>)

这在 Windows 上对我有用。我的 PATH 环境变量设置正确,因此conda activate base没有引发任何错误,但静静地失败了。


小智 10

conda init
Run Code Online (Sandbox Code Playgroud)

在命令提示符下运行此命令。

为我工作。


ere*_*wok 7

我刚刚用conda创建了一个新环境,情况有所不同。我sys.path是不是有点正确的,直到我想出办法。

结果,我想向其他人conda指出,因为您对的更改感到困惑,如果您已经升级了conda并创建了一个环境,它现在会告诉您(与以前的行为相反):

# To activate this environment, use
#
#     $ conda activate test
#
# To deactivate an active environment, use
#
#     $ conda deactivate
Run Code Online (Sandbox Code Playgroud)

因此,激活/停用环境的方法就是像上面那样做。

实际上,如果您从较旧版本的conda升级并尝试了上述操作,则可能会看到以下有用的消息(我这样做了):

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with

    $ echo ". ~/anaconda/etc/profile.d/conda.sh" >> ~/.bash_profile

or, for all users, enable conda with

    $ sudo ln -s ~/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh

The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH.  To do so, run

    $ conda activate

in your terminal, or to put the base environment on PATH permanently, run

    $ echo "conda activate" >> ~/.bash_profile

Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bash_profile file.  You should manually remove the line that looks like

    export PATH="~/anaconda/bin:$PATH"

^^^ The above line should NO LONGER be in your ~/.bash_profile file! ^^^
Run Code Online (Sandbox Code Playgroud)

更改以上内容可以解决sys.path激活的conda环境中的问题。

  • 以上说明假定Mac / Linux env引用了Bash或Bourne变体外壳。对于标准Windows CMD shell,该怎么办?我的miniconda3 / etc / profile.d文件夹仅包含conda.sh和conda.csh文件,但是没有Windows conda.bat版本。是否存在支持这些说明的方法?谢谢。 (6认同)
  • 我遵循了这些说明,尽管conda似乎可以正常工作,但我仍然遇到该错误。真奇怪 (4认同)

小智 7

尝试这个:

export PATH=/home/your_username/anaconda3/bin:$PATH
in ~/.bashrc
Run Code Online (Sandbox Code Playgroud)

然后source ~/.bashrc 这对我来说适用于同样的问题。


Shi*_*nka 5

在windows环境下使用“anaconda提示符”而不是“命令提示符”。