Using Spyder Python IDE with UV

I recently switched from Anaconda to UV for several reasons – the two most important being licensing (Anaconda cannot be easily used in a commercial setting) and speed of package resolving. Especially for image processing tasks, I love the Spyder IDE, but it was a little tricky getting it to run with the proper plugins, so below are the steps to get Spyder working nicely with UV.

Install UV

uv can be installed following the instructions on their homepage (https://docs.astral.sh/uv/) or by directly running

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

(Obvious advice of caution for copy and pasting scripts from the internet directly into a CLI)
Restart shell / add uv to PATH to make it available as command.

Install a python interpreter (e.g. 3.11):

uv python install 3.11

Create a project

cd /path/to/project
uv init hello-world
uv run hello-world

Above will create and init a project structure for the hello-world project and create a venv to run subsequent uv run commands in.
Project structure should look like:

.
├── .venv
│   ├── bin
│   ├── lib
│   └── pyvenv.cfg
├── .python-version
├── README.md
├── main.py
├── pyproject.toml
└── uv.lock

Add requirements

Using pandas as an example:

uv add pandas

This will resolve packages and install the latest compatible pandas into the venv as well as adding it to the project’s requirements.

Install Spyder to the system-wide uv cache:

uv tool install spyder

Add Spyder kernels into the uv-generated .venv (still within the same path from above):

uv pip install spyder-kernels

This will install spyder-kernels into the venv without adding them to the project’s requirements.

Then run spyder using:

uvx spyder

It should pick-up on the venv in the current working directory and all installed packages should be available. If it doesn’t work automatically, point the python interpreter to the one inside the .venv using the Spyder options or clicking the env hint on the bottom right of the Spyder window:

Inside spyder’s IPython console try:

import pandas

which should import the pandas that was installed into the venv earlier using the uv add command.