conda init 在 Windows 上的 bash 中不起作用 [英] conda init doesn't work in bash on Windows

查看:193
本文介绍了conda init 在 Windows 上的 bash 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Windows 上安装了 Git-Bash 和 conda,它提供了两个程序:C:\Program Files\Git\git-bash.exeC:\\Program Files\\Git\\bin\\bash.exe.

I install Git-Bash and conda on my Windows, which provides two program: C:\Program Files\Git\git-bash.exe and C:\\Program Files\\Git\\bin\\bash.exe.

后者,C:\\Program Files\\Git\\bin\\bash.exe,不能在 conda 中正常工作.当我尝试 conda acitvate base 时,我收到一条消息:

The latter, C:\\Program Files\\Git\\bin\\bash.exe, does not work with conda properly. When I try to conda acitvate base, I get a message:

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 initconda init bash,然后关闭并重新打开 bash.exe,但它仍然保持不变.

I tried conda init and conda init bash, then close and re-open the bash.exe, but it just remains the same.

知道如何解决问题吗?

我很关心这个问题,因为 VSCode 的集成终端使用了它.我尝试使用 C:\Program Files\Git\git-bash.exe 作为集成终端,但它打开了一个新窗口,而不是 VSCode 中的集成".

I am concerned with this issue because VSCode's Integrated Terminal uses it. I tried to use C:\Program Files\Git\git-bash.exe as Integrated Terminal, but it opens a new window, instead of 'Integrated' in VSCode.

git-base.exe 与 conda 配合良好,因此有关如何将 git-base.exe 设置为 VSCode 集成终端的指南也是可以接受的.

The git-base.exe works fine with conda, so guides on how to setup git-base.exe as VSCode Integrated Terminal is also acceptable.

任何帮助将不胜感激.

推荐答案

对我来说有两个问题:

  1. conda init 使用正确的初始化创建一个 .bash_profile 文件,但 git-bash.exe 加载 .bashrc(感谢澳大利亚的评论)
  2. 我的 bash 主目录不等于我的 Windows 主目录.Conda 创建了 C:\Users\\.bash_profile 并且 bash 需要 ~/.bashrc,但是 ~/ 不等于C:\Users\<用户名>\.
  1. conda init creates a .bash_profile file with the correct initialisation, but git-bash.exe loads .bashrc (thanks to Auss' comment)
  2. My bash home directory was not equal to my windows home directory. Conda created C:\Users\<username>\.bash_profile and bash needs ~/.bashrc, but ~/ was not equal to C:\Users\<username>\.

我的解决方案是

  • 从 VS Code 的 git 终端运行 code ~/.bashrc 以确保 .bashrc 在正确的位置创建
  • 复制C:\Users\\.bash_profile的内容并粘贴到打开的.bashrc
  • 重新打开 Git 终端
  • run code ~/.bashrc from the git terminal in VS Code to make sure the .bashrc is created in the right location
  • copy the contents of C:\Users\<username>\.bash_profile and paste into the opened .bashrc
  • Reopen the Git terminal

这篇关于conda init 在 Windows 上的 bash 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆