Install Conda on WSL2

Parham Motameni
4 min readJun 11, 2023

--

Rev: 2023–06–11

TL;DR

  • Within your WSL2 terminal download the latest Miniconda bash script for Linux from the official site using the following: wget <link to the installer>or curl <link to the installer>.
  • Run the script with bash bash Miniconda3-<version>-Linux-x86_64.sh, accept the license agreement, choose the installation location, and allow the installer to initialize Miniconda3 by running conda init.

Step by step

In this tutorial, we will go through the process of installing Conda, a popular package and environment manager, on Windows Subsystem for Linux 2 (WSL2).

Before we begin, make sure that WSL2 is installed and running on your Windows machine. If it’s not, please follow the official Microsoft documentation to install WSL2.

Step 1: Download Miniconda

Miniconda is a small, bootstrap version of Anaconda that includes only conda, Python, and the packages they depend on. We will be using Miniconda for this guide. To download the Miniconda installer, you will first need to navigate to the Miniconda Downloads page. In our case, we’re interested in the Linux installers. Copy the link address of the Miniconda version you want to install, which at the time of writing is “Latest — Conda 23.3.1 Python 3.10.10 released April 24, 2023.

Once you have copied the link, go back to your WSL2 terminal and download the bash script using wget or curl:

# Replace <link to miniconda installer>
# with the actual link you copied from the Miniconda page

curl -O <link to miniconda installer>
or
wget <link to miniconda installer>

Step 2: Run the Miniconda script

After you have downloaded the Miniconda script, you can run it to start the installation process. The script will be named something like Miniconda3-<version>-Linux-x86_64.sh. You can install it using bash like so:

bash Miniconda3-<version>-Linux-x86_64.sh

The script will start by displaying a license agreement, which you can scroll through using the Enterkey. Once you’ve read through the agreement, you can accept it by typing yes.

The installer will then ask for the location of the installation. You can choose the default location by pressing Enter.

Finally, the installer will ask if you want to initialize Miniconda3 by running conda init. It's recommended to allow this, so type yes and press Enter.

Step 3: Activate the installation

In order to activate the Conda environment, you will need to close and reopen your WSL2 terminal or source your bash profile:

source ~/.bashrc

After this, you should be able to use conda from the command line:

conda list

[Optional] Step 4: Update Conda

Just to make sure you are using the latest version of Conda, you can update it using the following command:

conda update -n base -c defaults conda

[Optional] Step 5: disable the base auto activate

If you’d prefer that conda’s base environment not be activated on startup,
set the auto_activate_base parameter to false:

conda config --set auto_activate_base false

Extra: Anaconda vs Miniconda

TL;DR: If you need a quick setup with a lot of packages for data science and scientific computing pre-installed, go for Anaconda. If you’re more space-conscious, prefer a minimalistic setup, or want to have more control over what is installed in your environment, go for Miniconda.

Comparison: Anaconda and Miniconda are both free distributions of Python and R for scientific computing and data science. They’re provided by Anaconda, Inc., and both use Conda as the package manager. However, there are a few differences between the two:

  1. Full vs Minimal: Anaconda is a full distribution of the central software in the PyData ecosystem and includes Python itself along with binaries for several hundred third-party open-source projects. On the other hand, Miniconda is a minimal installer for conda. It includes only conda, Python, the packages they depend on, and a small number of other useful packages.
  2. Size: Due to the included packages, the size of Anaconda is much larger than Miniconda. A typical Anaconda installation takes up hundreds of MBs, while Miniconda takes up tens of MBs.
  3. Flexibility: Since Anaconda comes pre-bundled with a lot of packages, it might be more convenient for beginners or for those who want to quickly set up an environment with a broad set of standard tools. Miniconda, however, is more flexible. It starts with the bare minimum, and you can install additional packages one by one as you need them, which can be very beneficial for maintaining clean and purpose-built environments.
  4. Installation Time: Due to its smaller size, Miniconda typically installs faster than Anaconda.

Conclusion

Congratulations, you have successfully installed Conda on WSL2! With Conda, you can create virtual environments for your Python projects, manage packages, and much more. Remember to check the official Conda documentation for more information on how to use this powerful tool.

In case of any issues during the installation process, refer to the official Conda and Miniconda documentation, or feel free to ask questions in the comment section below.

--

--