DEV Community

Davide Mauri
Davide Mauri

Posted on

5 4

WSL2, Windows, Python and Node: resolving some conflicts

Lately I've been working with Python and Node both on Windows on WSL (WSL2 specifically) and I noticed a certain number of inconveniences with WSL when having Python and Node installed on both systems. For example, some node packages were found when running node on WSL, even if I never installed them there. When that happened, the performances were horrible.

The reason is that, by default, Windows injects Windows path environment variable into WSL path.

For Node I was able to solve almost any problem using nvm, but with Python I had more challenges, so I decided to solve the problem right from at source.

First, tell WSL not to automatically add windows path to WSL. This can be done via wsl.conf file, as documented in the Advanced settings configuration in WSL.

Edit (or create if not already existing) the file:

sudo nano /etc/wsl.conf
Enter fullscreen mode Exit fullscreen mode

and then add the interop setting:

[interop]
appendWindowsPath = false
Enter fullscreen mode Exit fullscreen mode

Then close all WSL windows, open a Powershell or Command prompt and make sure WSL subsystem has shut down:

wsl --shutdown 
Enter fullscreen mode Exit fullscreen mode

Now you can re-open WSL session and check that the path doesn't automatically contain Windows paths:

echo $PATH | tr ":" "\n"
Enter fullscreen mode Exit fullscreen mode

The second - and last - step is to manually add path to the Windows tools you want to use with WSL too, for example VS Code. I'm using ZSH so I needed to update the .zshrc file and add VS Code path:

export PATH="$PATH:/mnt/c/Users/damauri/AppData/Local/Programs/Microsoft VS Code/bin"
Enter fullscreen mode Exit fullscreen mode

Done. No more conflicts or slow performances, but I can still use Windows tool on WSL. Perfect!

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

AWS Security LIVE! Stream

Stream AWS Security LIVE!

See how AWS is redefining security by design with simple, seamless solutions on Security LIVE!

Learn More

👋 Kindness is contagious

Dive into this informative piece, backed by our vibrant DEV Community

Whether you’re a novice or a pro, your perspective enriches our collective insight.

A simple “thank you” can lift someone’s spirits—share your gratitude in the comments!

On DEV, the power of shared knowledge paves a smoother path and tightens our community ties. Found value here? A quick thanks to the author makes a big impact.

Okay