# Install Conda in WSL (Guide to setting up Miniconda or Anaconda in WSL) ## Why we need to crete conda? The purpose of creating the virtual environment tool 'Conda' is to manage dependencies efficiently, avoid conflicts between different operating systems (Linux, macOS, and Windows), and allow the use of different Python versions for different projects. ## Step to install Conda in WSL ### Step 1: Update WSL & Install Dependencies ```wsl= sudo apt update && sudo apt upgrade -y sudo apt install wget curl -y ``` ### Step 2: Install Miniconda (Recommended) 1. Download the latest Miniconda installer: ```bash= wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh ``` 2. Run the installer: ```bash= bash Miniconda3-latest-Linux-x86_64.sh ``` 3. Follow the on-screen prompts: - Press Enter to continue. - Scroll through the license (Space to move faster). - Type yes to accept. - Choose the installation directory (default: ~/miniconda3). - Type yes when asked to initialize Conda. 4. Restart your shell: ```bash= source ~/.bashrc ``` 5. Verify installation: ```bash= conda --version ``` ### (Alternative) Step 2: Install Full Anaconda For full Anaconda, use: ```bash= wget https://repo.anaconda.com/archive/Anaconda3-latest-Linux-x86_64.sh bash Anaconda3-latest-Linux-x86_64.sh source ~/.bashrc conda --version ``` ### Step 3: Configure Conda for WSL To avoid potential issues in WSL: 1. Prevent Conda from activating the base environment automatically: ```bash= conda config --set auto_activate_base false ``` 2. Restart your shell: ```bash= source ~/.bashrc ``` 3. To activate Conda manually, use: ```bash= conda activate ``` ### Step 4: Test Conda Check Latest Python Version in a Specific Conda Channel (usaully the last one) ```bash= conda search python --channel defaults ``` ![image](https://hackmd.io/_uploads/S1EPSnu_1g.png) And then paste the following code below: ```bash= conda create -n test_env python=3.13.1 -y conda activate test_env python --version ``` ### Step 5: (Optional) Add Conda to .bashrc or .zshrc If Conda isn’t recognized: ```bash= echo 'export PATH="$HOME/miniconda3/bin:$PATH"' >> ~/.bashrc source ~/.bashrc ``` For Zsh users: ```bash= echo 'export PATH="$HOME/miniconda3/bin:$PATH"' >> ~/.zshrc source ~/.zshrc ``` ### Step 6: Keep Conda Updated ```bash conda update -n base -c defaults conda ``` And now you can use Conda in WSL!