Install Miniconda and Anaconda on WSL 2 or Linux
Anaconda and Miniconda are commonly used by Python developers to create Python virtual environments with different Python versions and packages. This article shows you how to install Miniconda or Anaconda on a WSL2 Debian GNU Linux distro. This can be applied to other WSL2 distros or Linux directly with small changes of the command lines.
This article provides detailed steps of installing Miniconda. The steps are the same for Anaconda installation and the only difference is that the installer packages are different.
WSL 2
You can install WSL 2 following this article - Install Windows Subsystem for Linux on a Non-System Drive.
Download Miniconda Linux installer
The installer can be downloaded from the official web page: Miniconda — Conda documentation.
For this article, I am downloading this specific version: Miniconda3 Linux 64-bit. This can be done by running the following command in your WSL distro:
sudo apt-get update sudo apt-get install wget wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
Validate checksum
SHA256 hash is '78f39f9bae971ec1ae7969f0516017f2413f17796670f7040725dd83fcff5689' provided by the official page.
We can verify using the following command line:
$ sha256sum Miniconda3-py39_4.12.0-Linux-x86_64.sh 78f39f9bae971ec1ae7969f0516017f2413f17796670f7040725dd83fcff5689 Miniconda3-py39_4.12.0-Linux-x86_64.sh
The output is consistent with the expected. This is to ensure the binary package is not modified.
Install Miniconda
Now we can install it by running the following command:
sh ./Miniconda3-py39_4.12.0-Linux-x86_64.sh
Press ENTER to continue.
When asked, you need to accept license by type yes to continue:
Do you accept the license terms? [yes|no] [no] >>> Please answer 'yes' or 'no':'
And then press ENTER to continue.
Miniconda3 will now be installed into this location: /home/kontext/miniconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/home/kontext/miniconda3] >>>
You can also init Miniconda by typing yes:
Preparing transaction: done Executing transaction: done installation finished. Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no] [no] >>> yes no change /home/kontext/miniconda3/condabin/conda no change /home/kontext/miniconda3/bin/conda no change /home/kontext/miniconda3/bin/conda-env no change /home/kontext/miniconda3/bin/activate no change /home/kontext/miniconda3/bin/deactivate no change /home/kontext/miniconda3/etc/profile.d/conda.sh no change /home/kontext/miniconda3/etc/fish/conf.d/conda.fish no change /home/kontext/miniconda3/shell/condabin/Conda.psm1 no change /home/kontext/miniconda3/shell/condabin/conda-hook.ps1 no change /home/kontext/miniconda3/lib/python3.9/site-packages/xontrib/conda.xsh no change /home/kontext/miniconda3/etc/profile.d/conda.csh modified /home/kontext/.bashrc ==> For changes to take effect, close and re-open your current shell. <== 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 Thank you for installing Miniconda3!
Now you can use conda command to manage your Python virtual environments. Refer to page for more information: Create Environments with Different Python Versions in Anaconda.
References
Miniconda — Conda documentation