Anaconda and Git Bash in Windows - conda: command not found

前端 未结 4 1807
后悔当初
后悔当初 2020-12-08 03:31

I\'ve installed Anaconda and set Path environment variable to C:\\Anaconda3; C:\\Anaconda3\\Scripts.

Then I try to run in Git Bash

conda

相关标签:
4条回答
  • 2020-12-08 03:46

    To be able to run conda on gitbash you need to add it to the path. Many times I've seen that's done by default - as shown in the setup for this workshop. If it doesn't, as it seems your case, then you can run their setup directly by running:

    . /c/Anaconda3/etc/profile.d/conda.sh
    

    After running that you should be able to run conda commands.

    To keep this setup permanently you can add such line on your .profile or .bashrc file (read more about their differences). A way of doing so is running the follwing:

    echo ". /c/Anaconda3/etc/profile.d/conda.sh" >> ~/.profile
    

    You may encounter problems if the path where Anaconda was installed contains spaces (e.g., C:\Program Files). In that case you would need to change the anaconda location or edit conda.sh script with something like:

    sed -e '/^_CONDA_EXE=.*/a alias myconda="${_CONDA_EXE/ /\\\\ }"' \
        -e 's/\$_CONDA_EXE/myconda/g' /c/Program\ Files/Anaconda3/etc/profile.d/conda.sh > conda_start.sh
    

    This sed command inserts a new alias definition myconda which changes the anaconda path from Program Files to Program\ Files so bash doesn't stop whit an error like:

    bash: /c/Program: No such file or directory
    

    The second sed command replaces the _CONDA_EXE variable by the new alias created.

    Since the above doesn't modify the file provided by anaconda, you will need to update your .profile file to load the file we've just created, conda_start.sh, instead.

    0 讨论(0)
  • 2020-12-08 03:50

    in Git bash,

    conda init bash
    

    will work well.

    if you wanna use different shell,

    conda init [shell_name]
    

    [shell_name] can be: bash, cmd.exe, fish, powershell, tcsh, xonsh, zsh

    use conda init --help for more info.

    0 讨论(0)
  • 2020-12-08 04:07

    Joining @dvdgc13. In my case, I fixed the problem by adding

    . C:/Users/user/Anaconda3/etc/profile.d/conda.sh
    

    to my .bash_profile.

    0 讨论(0)
  • 2020-12-08 04:11

    For MAC users, do this:

    $ echo ". /usr/local/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
    $ source ~/.bashrc
    
    0 讨论(0)
提交回复
热议问题