【问题标题】:Anaconda 2019.03: activate break in win10 git-bashAnaconda 2019.03:在 win10 git-bash 中激活中断
【发布时间】:2019-08-28 12:28:26
【问题描述】:

我一直在win10系统中使用anaconda 2018.12(conda 4.5.12)和git-bash,在我按照以下错误信息操作后效果很好。

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 ". C:\Users\user\Anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc

or, for all users, enable conda with

    $ sudo ln -s C:\Users\user\Anaconda3/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" >> ~/.bashrc

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

    export PATH="C:\Users\user\Anaconda3/bin:$PATH"

^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^

但是,在我将 anaconda 升级到 2019.03(conda 4.6.11)后,我收到了以下错误消息

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'.

通过运行conda init bash 我的 .bash_profile 中有以下代码

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
eval "$('C:\Users\user\Anaconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
# <<< conda initialize <<<

然后我每次尝试使用 conda 推荐时都会得到CommandNotFoundError: No command 'conda conda'.

Conda 似乎在 cmd.exe 中可以正常工作。 有人遇到同样的问题吗?

【问题讨论】:

标签: python anaconda git-bash


【解决方案1】:

我已经解决了这个烦恼,将下面添加的命令从 ~\.bash_profile 移动到 ~\.bashrc 并且一切正常

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
eval "$('/c/Miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
# <<< conda initialize <<<

从 VSCode 启动终端好像没有运行.bash_profile

【讨论】:

    【解决方案2】:

    我使用 conda install conda=4.6.14 升级到 conda 4.6.14,这个错误已为我解决。

    【讨论】:

    • 对我来说它在 conda 4.9.2 中失败了
    猜你喜欢
    • 2021-01-18
    • 2019-08-19
    • 2018-11-26
    • 2019-06-07
    • 2012-05-14
    • 2017-09-07
    • 2020-01-15
    相关资源
    最近更新 更多