Use Mamba as a faster drop-in replacement for conda
Mamba is a project originally developed by the Quantstack team. They went in and solved some of the annoyances with the conda package manager - specifically the problem of how long it takes to solve an environment specification.
Mamba is available on conda-forge and PyPI. Follow the instructions on the mamba repo to install it.
If you have muscle memory and want to make the switch from
mamba as easy as possible, you can use a shell alias inside your sourced
See the page Create shell command aliases for your commonly used commands for more information on shell aliases.
Create shell command aliases for your commonly used commands
Shell aliases can save you keystrokes, which save time. That time saved is compound interest over long time horizons!
Shell aliases are easy to create. In your shell initializer script, use the following syntax, using
ls being aliased to
exa with configuration flags at the end as an example:
alias ls="exa --long"
ls at the shell will instead execute
exa! (To know what is
exa, see Install a suite of really cool utilities on your machine using homebrew.)
In order for these shell aliases to take effect each time you open up your shell, you should ensure that they get sourced in your shell initialization script (see: Take full control of your shell environment variables for more information). You have one of two options:
.bashrc(or analogous) file, or
~/.aliases, which you source inside your shell initialization script file (i.e.
I recommend the second option as doing so means you'll be putting into practice the philosophy of having clear categories of things in one place.
In my dotfiles repository, I have a
.shell_aliases directory which contains a full suite of aliases that I have installed.
Other external links that showcase shell aliases that could serve as inspiration for your personal collection include:
And finally, to top it off, Twitter user @ctrlshifti suggests aliasing please to sudo for a pleasant experience at the terminal:
alias please="sudo" # Now you type: # please apt-get update # please apt-get upgrade # etc...
Bootstrap your base conda environment
In a pinch, you might want to muck around on your system with some quick-and-dirty experiment. Having a suite of packages inside your base environment can be handy. It's like having a scratch environment available.
I would recommend bootstrapping your base anaconda environment with some basic data science packages.
conda activate base conda install -c conda-forge \ scipy numpy pandas matplotlib \ numpy jupyter jupyterlab \ scikit-learn ipython ipykernel \ ipywidgets mamba
Doing so gives you an environment where you can quickly prototype new things
without necessarily going through the overhead of creating an entirely new project
(and with it, a full conda environment).
Of course, the alternative is to set up a
in which you install packages on-the-fly.
mamba can be helpful if you want a faster drop-in replacement for
(see: Use Mamba as a faster drop-in replacement for conda for more information.)
Install Anaconda on your machine
Anaconda is a way to get a Python installed on your system.
One of the neat but oftentimes confusing things about Python is that you can have multiple Python executables living around on your system. Anaconda makes it easy for you to:
Why is this a good thing? Primarily because you might have individual projects that need different version of Python and different versions of packages that are built for Python. Also, default Python installations, such as the ones shipped with older versions of macOS, tend to be versions behind the latest, which is to the detriment of your projects. Some built-in apps in an operating system may depend on that old version of Python (such as iPhoto), which means if you mess up the installation, you might break those built-in apps. Hence, you will want a tool that lets you easily create isolated Python environments.
The Anaconda Python distribution fulfills the following key needs:
Installing Anaconda on your local machine thus helps you get easy access to Python, Jupyter (see: Use Jupyter as an experimentation playground), and other tools for modelling and analysis.
If you're on macOS: I'm assuming you have installed
homebrew (see: Install homebrew on your machine) and
wget. Then, install Miniconda, which will be a lighter-weight installer, using the following command:
cd ~ wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O anaconda.sh
This will send you to your home directory, and then download the Miniconda bash script installer from Anaconda's download page.
If you're on Linux: Make sure you have
wget available on your system. Then:
cd ~ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O anaconda.sh
This will download the Miniconda installer for Linux operating sytems onto your home directory.
If you don't have
wget: You can head over to the Miniconda docs and download the bash installer to whatever location you want (the home directory is a convenient place). Rename it to
anaconda.sh to stay compatible with the instructions below.
Now, install Anaconda:
bash anaconda.sh -b -p $HOME/anaconda/
This will install the Anaconda distribution of Python onto your system inside your home directory. You can now install packages at will, without needing sudo privileges!