How to add Conda to Git Bash (Windows)
For windows users, is not common to use the bash
command in the command prompt. Also, in Git bash (the git console with some Linux commands) in Windows. For a Linux user, change to windows could be a bit annoying when we try to make some changes in the system via commands instead of the GUI application.
One example is the fastly way to use python/conda/git in the same console. In this case Git Bash. But when you install Anaconda in Windows, you should open a dedicated command prompt to use Anaconda. In addition, a dedicated console called Git Bash controls your repositories.
For that, today I gonna show you how to add the conda
command into the Git Bash to get it all in one python-conda-git bash.
Installing Conda
This step is easy, you can found how to install it on windows pressing here.
Once you have installed Conda, go to the folder: Anaconda/etc/profile.d/
This will open a new instance of Git Bash to the correct directory.
Now, so long as the path to your file has no spaces, you can add conda.sh
to your .bashrc
with this simple command:
echo ". ${PWD}/conda.sh" >> ~/.bashrc
If the path does contain spaces (such as in your username), you will need to add single quotes in the command like so:
echo ". '${PWD}'/conda.sh" >> ~/.bashrc
After running this command, you will need to close Git Bash and reopen it for it to take effect.
Then, reopen Git bash and tap conda
Troubles with python
If you already installed conda in your system (but no python), when you try to start python into git bash, you'll see a message like this:
To solve this, we will use the python installed within Conda environment, similar to above, we need to add this line into the file .bashrc :
alias python=’winpty /C/Users/Adrian/anaconda3/python.exe’
.bashrc
should be like thisFinally, we can open Python into Git bash:
I hope you enjoyed this post :D :D