Long time ago I switched from the default Ubuntu shell (bash I guess) to fish shell. I'm still far from being an fish shell power user, but I like the out of the box experince with auto-completion etc. Anyways, today I wanted to play with another technology new to me, called conda. Conda is an package manager for installing and managing software packages (you can read in detail about it on the conda page).
Conda comes in two versions:
The conda manual contains an overview of both here. I chose to use the light-weight option, namely miniconda. On Linux the installer is basically a shell-script which will self-extract into your home directory in my case ~/miniconda3
(or whereever you chose to put it).
cd ~/Downloads
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
This will install the Linux x86 64 bit version of miniconda for Python 3.
During the installation you can choose to let the installer modify your ~/.bashrc
to add ~/miniconda3/bin
to your PATH
environment variable, such that you can run the conda commands like any other system level command (just one small cavat is that miniconda also ships with its own version of Python, so this will also take precedense over the one system installed one). That didn't work well for me, because the miniconda version of Python has some packages removed (e.g. test which some Python packages rely on even though it is meant for internal testing). Note that fish does not use ~/.bashrc
. Instead fish uses ~/.config/fish/config.fish
, so to set the PATH
environmenbt variable I added:
set -x CONDA_PATH $HOME/miniconda3/bin
function condaon
set -x PATH $CONDA_PATH $PATH
echo "Hello Conda (adding" $CONDA_PATH "to PATH)"
end
Now I can write condaon
in my terminal, which will add the miniconda directory to my path.
Fish provides set
to manipulate environment vaiables. The first arguement -x
will export the enviroment variable to child processes. The second arguement is the name of the environment varaible we want to set (in this case PATH
). Finally we provide a space seperated list of value to use. For more detailed documentation use man set
.
Open a new fish shell and try typing conda help
and you should be ready to go.
To use Conda's environment activation/deactivation in the fish shell source the file from ~/miniconda3/etc/fish/conf.d/conda.fish
to automatically load the needed functions when a new fish shell is started. This is done by adding source ~/miniconda3/etc/fish/conf.d/conda.fish
to config.fish
.
As a small note, I normally have my config files stored in Dropbox so when configuring a new machine I just need to create the symlinks. That works pretty well.
Note you need fish shell version +2.2.x. Check your version with fish --version
, if you are using Ubuntu you can upgrade to a newer version with the Fish shell maintainers PPA.
Currently Conda's environment activation/deactivation does not fully support the fish shell. There is an open pull-request which adds support though. So when it gets merged we should be able to do a conda update conda
and use the provided script.
Until then we can use the script provided in the pull-request:
cd ~/.config/fish
wget https://raw.githubusercontent.com/aldanor/conda/fish/bin/conda.fish
Source the file from ~/.config/fish/config.fish
to automatically load the needed functions when a new fish shell is started. This is done by adding source ~/.config/fish/conda.fish
to config.fish
.
As a small note, I normally have my config files stored in Dropbox so when configuring a new machine I just need to create the symlinks. That works pretty well.
Note you need fish shell version +2.2.x. Check your version with fish --version
, if you are using Ubuntu you can upgrade to a newer version with the Fish shell maintainers PPA.
If you haven't used Conda before, you can try this just to get started :) It will install the newest version of the jupyter notebook in a Conda environment called jupyter
.
conda create --name jupyter jupyter
Activate the environment:
conda activate jupyter
Launch the Jupyter notebook:
jupyter notebook
Deactivate the environment again:
conda deactivate
Have fun :)