A Fresh Start: Reinstalling and Configuring WSL for Multiple Environments

WSL
quarto
git
PyCaret
mamba
Keras
Author

JM Ascacibar

Published

June 13, 2024

A Fresh Start: Reinstalling and Configuring WSL for Multiple Environments

I don’t know what happened but when I turned on the computer today, the connection between VSCode and WSL was broken. I tried to fix it but it didn’t work. So after an hour of despair, I decided to use heavy ordinance and make a fresh start.

Important: I have backed up all my important files from my WSL environment

Uninstall Everything

So the first obviuos step is to uninstall WSL. You don’t need to be an engineer genius to do this. Just open a PowerShell terminal or you can also do it from uninstall programs in the control panel.

Next, you need to uninstall VSCode from Windows and this procedure is simple but a bit tricky. You need to uninstall the program and also delete the settings and extensions. Go to uninstall programs in the control panel and uninstall VSCode. Then go to the following folders %APPDATA%\Code, %USERPROFILE%\.vscode and delete them. More info here

I don’t know why but also my terminal blows up so I need to uninstall it. Go to the control panel and uninstall the terminal. Easy.

Reinstall Everything

WSL

After throwing everything out of the window, it’s time to reinstall everything. First, you need to install WSL. You can follow the instructions from the official Microsoft documentation or just type in your powershell terminal as administrator the following command:

wsl --install

Terminal

I uninstalled the terminal so I need to install it again. You can install it from the Microsoft Store. Just type in the search bar Windows Terminal and install it.

VSCode

Now it’s time to install VSCode. Once installed, you need to install the WSL extension. You can do this by going to the extensions tab and searching for WSL. Install it and you are ready to go. Here is the documentation

VSCode extensions for DS/ML

We don’t need to reinvent the wheel. Here is a list of the must-have extensions and a tutorial.

Set up Git and SSH in WSL

I have a GitHub account and I need to set up Git and SSH in WSL. First, set your username and email in Git. Open a terminal and type the following commands:

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

Next, you need to generate an SSH key. Open your terminal and type the following command:

ssh-keygen

And copy your public key to your clipboard:

$ cat .ssh/id_rsa.pub

Now you need to add your SSH key to your GitHub account. Go to your GitHub account and click on your profile picture and then settings. Click on SSH and GPG keys and then New SSH key. Paste your key and you are ready to go.

Install Mamba

We need to install a package manager. I used Conda but Mamba is Conda but faster. Check the documentation and install miniforge for Linux.

Install Quarto

I need to install Quarto for my projects and website. You can check the documentation and install it or just open your terminal in Linux or WSL and use the wget command to download the Debian package from GitHub. Here is the command you need to use:

wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.45/quarto-1.5.45-linux-amd64.deb

Once the download is complete, you can install the package using dpkg, which is the package manager for Debian-based distributions. You might need to run this command with sudo to ensure you have the necessary permissions to install software:

sudo dpkg -i quarto-1.5.45-linux-amd64.deb

Next steps is to install the VSCode extension. You can find it here

Creating Environments

PyCaret

I need to create a PyCaret environment. Before I was using all my libraries in the same base environment but now I want to create a separate environment for libraries that install a lot of dependencies and can potentially break my base environment.

First, I need to create a new environment. I will use Mamba to create the environment. Open your terminal and type the following command:

mamba create -n pycaret_env python=3.11

If you need to remove an environment, you can use the following command:

mamba remove pycaret_env

This is going to install Python 3.11 and create a new environment called pycaret_env. Next step is to activate the environment. You can do this by typing the following command:

mamba activate pycaret_env

Now you can install PyCaret and all the dependencies. You can do this by typing the following command:

pip install pycaret[full]

Installing Keras

We are going to create another environment for Keras. Same steps as before.

To use Keras 3, you will also need to install a backend framework – either JAX, TensorFlow, or PyTorch. Check before anything the requirements of Keras 3. Here is the documentation

So we are going to install all of them. Follow the following documentation to install each of them:

Conclusion

I hope this guide helps you to reinstall and configure your WSL environment. I know it’s a pain but sometimes it’s necessary to start from scratch.

Back to top