Software tools & Python recap Jotter

I want my Spyder to see a venv that I made in WSL. What path should I use?

Run Spyder inside WSL

On Windows 11 with WSLg, you can install/run Spyder inside WSL:

sudo apt update
sudo apt install spyder
spyder

Then use:

/home/yourusername/yourproject/.venv/bin/python

With Spyder is running inside WSL

Use the normal Linux path to the venv’s Python executable:

/home/yourusername/yourproject/.venv/bin/python

Example:

/home/steve/code/myproject/.venv/bin/python

You can find the exact path from inside WSL with:

source /path/to/yourproject/.venv/bin/activate
which python

Then in Spyder set that path as the Python interpreter.

You may also need to install the kernel packages into that venv:

python -m pip install ipykernel spyder-kernels

Can I run Spyder inside WSL and get a full GUI?

Yes — if you’re using WSL2, Spyder can run inside WSL and show a normal Linux GUI window on Windows.

The easiest case is Windows 11, because WSLg provides GUI support automatically.

Basic setup:

sudo apt update
sudo apt install spyder
spyder

If a Spyder window appears, you’re done.

If it doesn’t, make sure WSL is up to date from PowerShell:

wsl --update
wsl --shutdown

Then reopen WSL and try again:

spyder

You can test WSL GUI support with:

sudo apt install x11-apps
xclock

If a small clock window appears, GUI apps from WSL are working.

To make Spyder use your WSL venv, use the Linux path:

/home/yourusername/yourproject/.venv/bin/python

You may also need:

/home/yourusername/yourproject/.venv/bin/python -m pip install spyder-kernels

On older Windows 10 setups without WSLg, you may need an X server such as VcXsrv or X410, but on modern Windows 11 this is usually unnecessary.

I can't start spyder from WSL.

Try these in order. The key test is whether any GUI app can open from WSL.

1. Check the exact error

In WSL, run:

spyder

If it fails, try:

QT_DEBUG_PLUGINS=1 spyder

or:

spyder --debug

If you paste the last 20 lines of that error, I can pinpoint it.

—

2. Make sure the distro is WSL2

From PowerShell:

wsl -l -v

Your distro should say VERSION 2.

If it says 1, convert it:

wsl --set-version YourDistroName 2

Then:

wsl --shutdown

Reopen WSL.

—

3. Update WSL GUI support

From PowerShell:

wsl --update
wsl --shutdown

Then reopen WSL.

—

4. Test a simple GUI app

Inside WSL:

sudo apt update
sudo apt install -y x11-apps
xclock

If xclock opens, WSL GUI support is working.

If xclock does not open, Spyder is not the problem yet — WSL GUI support is.

—

5. Install Spyder from Ubuntu packages

The simplest working install is usually:

sudo apt update
sudo apt install -y spyder
spyder

If spyder is not found after that, log out and back into WSL, or run:

hash -r
spyder

—

6. If Spyder fails but xclock works

Install common Qt/X11 libraries:

sudo apt install -y \
  libxcb-xinerama0 \
  libxcb-cursor0 \
  libxkbcommon-x11-0 \
  libgl1 \
  libegl1 \
  libfontconfig1 \
  libdbus-1-3 \
  libnss3

Then try again:

spyder

If it still fails, run:

QT_DEBUG_PLUGINS=1 spyder

and look for lines mentioning missing libraries or xcb.

—

7. Check your DISPLAY variable

Inside WSL:

echo "$DISPLAY"
echo "$WAYLAND_DISPLAY"

For modern WSLg on Windows 11, you usually want:

DISPLAY=:0

or at least a non-empty DISPLAY.

If your ~/.bashrc contains something like:

export DISPLAY=$(ip route ...)

comment it out temporarily, then restart WSL.

You can test with:

unset DISPLAY
export DISPLAY=:0
xclock
spyder

—

8. If you installed Spyder with pip

A pip Spyder install can be more fragile because it needs many GUI dependencies. If you used:

pip install spyder

try the Ubuntu version first:

sudo apt install -y spyder

Or use a dedicated venv:

sudo apt install -y python3-venv python3-pip
python3 -m venv ~/spyder-env
~/spyder-env/bin/pip install -U pip
~/spyder-env/bin/pip install spyder spyder-kernels
~/spyder-env/bin/spyder

—

9. Windows 10 note

If you are on Windows 10, WSLg may not be available. You may need an X server such as:

  • VcXsrv
  • X410

Then set DISPLAY to your Windows host IP, for example:

export DISPLAY=$(ip route list default | awk '{print $3}'):0
xclock

On Windows 11, this is usually unnecessary.

—

10. Quick diagnostic commands

Run these and send the output if it still fails:

wsl.exe -l -v

from PowerShell, then inside WSL:

cat /etc/os-release
echo "$DISPLAY"
echo "$WAYLAND_DISPLAY"
ls /mnt/wslg
which spyder
spyder --version || true
QT_DEBUG_PLUGINS=1 spyder

WSL GUI support is not working

We need answer to user: "*" then "not working". Context: They said can't start spyder from WSL. I gave diagnostics. They likely mean WSL GUI support not working. Need concise but helpful. Need likely ask for outputs? Could provide targeted fixes for WSLg not working. Need maybe Windows version, wsl –version, distro, error. Since user says not working. Need guide. Need perhaps mention if xclock fails. Need steps: update Windows, WSL, enable virtual machine platform, WSLg requires Win 11 or Win10 21H2+ with WSL 0.58+. Check wsl –version. Ensure GUI apps allowed, no old DISPLAY. Restart wsl –shutdown. Check C:\Users\<User>\.wslconfig maybe disable wslg? [wsl2] guiApplications=false? Also check HKEY? Maybe if using work/school PC or GPU driver issues. Also check wslg distro? Need commands: powershell: wsl –update –web-download; wsl –shutdown; wsl –version. In WSL: ls /mnt/wslg; echo $DISPLAY; maybe set export DISPLAY=:0. Also if no /mnt/wslg, WSLg not active. Need maybe install from Store not wsl.exe? Use winget? Also possible nested virtualization not needed? For WSL2. Need mention if using VMware/VMware Workstation maybe WSL2 issues? But GUI support requires WSL2. Could suggest test with notepad: sudo apt install x11-apps; xclock. Also if DISPLAY set weird from old instructions, unset and set to :0. Need maybe ask for output of wsl –version and error. Need answer in English. final only.

If WSL GUI support itself is not working, fix that first — Spyder will not start until xclock or another GUI app opens.

Try this sequence.

—

1. Confirm you are using WSL2

From PowerShell:

wsl -l -v

Your distro must show:

VERSION 2

If it shows 1, convert it:

wsl --set-version YourDistroName 2

Then:

wsl --shutdown

—

2. Update WSL itself

From PowerShell:

wsl --update
wsl --shutdown

Then reopen your WSL distro.

Check:

wsl --version

You want a fairly recent WSL version. WSLg needs modern WSL, not the old Windows optional feature version.

—

3. Check whether WSLg is present

Inside WSL:

ls /mnt/wslg

If WSLg is working, you should see things like:

runtime-dir  distro  .X11-unix

If /mnt/wslg does not exist, WSLg is not active.

—

4. Remove old manual DISPLAY settings

Old tutorials often tell you to set DISPLAY to a Windows IP address. That can break modern WSLg.

Check:

echo "$DISPLAY"
echo "$WAYLAND_DISPLAY"

Then try:

unset DISPLAY
export DISPLAY=:0

Now test:

sudo apt update
sudo apt install -y x11-apps
xclock

If a clock appears, GUI is working.

If you have a line like this in ~/.bashrc:

export DISPLAY=$(ip route list default | awk '{print $3}'):0

temporarily comment it out:

# export DISPLAY=$(ip route list default | awk '{print $3}'):0

Then restart WSL:

wsl --shutdown

—

5. Make sure Windows supports WSLg

WSLg works best on:

  • Windows 11, or
  • Windows 10 21H2 or newer with updated WSL from the Store/web

From PowerShell:

winver

If you are on an old Windows build, update Windows.

—

6. Check for a .wslconfig disabling GUI features

From PowerShell, open/create:

notepad $env:USERPROFILE\.wslconfig

Make sure it does not contain something like:

[wsl2]
guiApplications=false

If it does, remove that or set:

[wsl2]
guiApplications=true

Save, then:

wsl --shutdown

—

7. Reinstall/update the WSL GUI components

From PowerShell, try:

wsl --update --web-download
wsl --shutdown

Then open WSL again and test:

DISPLAY=:0 xclock

—

8. If xclock still fails

Run these and send the output:

From PowerShell:

wsl --version
wsl -l -v
winver

From inside WSL:

cat /etc/os-release
echo "$DISPLAY"
echo "$WAYLAND_DISPLAY"
ls /mnt/wslg
DISPLAY=:0 xclock

The important clue is whether /mnt/wslg exists and what xclock prints.

How to set up VSCode to use a Python virtual environment?

In VSCode:

  1. Install the Python extension.
  2. Open your project folder in VSCode.
  3. Create a virtual environment, e.g.:
python3 -m venv .venv
  1. Activate it:
# Linux/macOS
source .venv/bin/activate

# Windows
.venv\Scripts\activate
  1. In VSCode, open the command palette:
Ctrl+Shift+P   # Linux/Windows
Cmd+Shift+P    # macOS
  1. Run:
Python: Select Interpreter
  1. Choose the interpreter inside your virtual environment:
./.venv/bin/python

or on Windows:

.venv\Scripts\python.exe

VSCode should then use that environment for running Python files, linting, debugging, and integrated terminal activation.

Optional .vscode/settings.json:

{
  "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"
}

For Windows use:

{
  "python.defaultInterpreterPath": "${workspaceFolder}/.venv/Scripts/python.exe"
}

Author: Breanndán Ó Nualláin <o@uva.nl>

Date: 2026-09-03 Thu 12:06