我在 Windows 上安装了 Git-Bash 和 conda,它提供了两个程序:
C:\Program Files\Git\git-bash.exe
和 C:\\Program Files\\Git\\bin\\bash.exe
。
后者,
C:\\Program Files\\Git\\bin\\bash.exe
,不能与 conda 正常工作。当我尝试 conda acitvate base
时,我收到一条消息:
Administrator@##### MINGW64 /bin
$ conda --version
conda 4.7.12
Administrator@##### MINGW64 /bin
$ conda activate base
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
和conda init bash
,然后关闭并重新打开bash.exe
,但它仍然保持不变。
知道如何解决这个问题吗?
我担心这个问题,因为 VSCode 的集成终端使用它。我尝试使用
C:\Program Files\Git\git-bash.exe
作为集成终端,但它会打开一个新窗口,而不是 VSCode 中的“集成”。
git-base.exe
可以与 conda 配合使用,因此也可以接受有关如何将 git-base.exe
设置为 VSCode 集成终端的指南。
如有任何帮助,我们将不胜感激。
对我来说有两个问题:
conda init
创建一个具有正确初始化的 .bash_profile
文件,但是 git-bash.exe
加载 .bashrc
(感谢 Auss' 评论)C:\Users\<username>\.bash_profile
并且 bash 需要 ~/.bashrc
,但是 ~/
不等于 C:\Users\<username>\
。我的解决方案是
code ~/.bashrc
,以确保在正确的位置创建 .bashrc
C:\Users\<username>\.bash_profile
的内容并粘贴到打开的.bashrc
将.bash_profile中的配置追加到.bashrc文件中
conda init bash
cat ~/.bash_profile >> ~/.bashrc
conda activate $ENVNAME
bash 重新启动后应该可以工作。
仅对少数人有用:
conda init
需要在其后面有 bash
。因此,请使用 conda init bash
或任何其他 shell 名称。愚蠢的错误,但简单的修复。
就我而言,只需在
conda init bash
中输入 git bash shell
即可解决问题。😉