Fixing "DLL load failed" and Import Errors with PySide6 on Windows

Understanding why PySide6 imports fail in certain IDEs and how to fix it
Heads up! You've already completed this tutorial.

I installed PySide6, but I'm unable to import anything from it. I get an ImportError: DLL load failed: The specified procedure could not be found. I'm using Windows 10 and have Spyder, PyCharm, and Jupyter Notebook available. I've also seen errors about needing only one instance of QApplication. How do I get PySide6 working?

There are two separate issues that often get tangled here:

  1. A genuine DLL or installation problem with PySide6 itself.
  2. A conflict between Qt libraries when your IDE already uses Qt internally.

Let's look at each one.

Checking your PySide6 installation

Before worrying about IDE conflicts, it's worth confirming that PySide6 is installed correctly and works on its own. The simplest way to do this is to open a plain command prompt (not inside any IDE) and test the import directly.

On Windows, open Command Prompt or PowerShell and run:

sh
python -c "from PySide6.QtWidgets import QApplication; print('PySide6 is working!')"

If this prints PySide6 is working!, then PySide6 itself is fine and the problem is with your IDE environment. Skip ahead to the IDE section below.

If you still get the DLL load failed error here, the installation needs attention.

Reinstalling PySide6

The most reliable fix for DLL-related import errors is a clean reinstall:

sh
pip uninstall PySide6 PySide6-Essentials PySide6-Addons shiboken6
pip install PySide6

This removes all PySide6 components and reinstalls them fresh, making sure everything is consistent. For detailed installation steps, see our guide on installing PySide6 on Windows.

Check your Python version

PySide6 requires a compatible Python version. As of writing, PySide6 supports Python 3.7 and above, but you should always use a recent, stable version (Python 3.9+ is recommended). You can check your Python version with:

Bring Your PyQt/PySide Application to Market — Specialized launch support for scientific and engineering software built using Python & Qt.

Find out More

sh
python --version

If you're using a very old or very new Python release, there may not be a compatible PySide6 wheel available, which can cause installation issues.

Virtual environments help

If you have multiple Python projects or packages installed, conflicts between them can cause mysterious DLL errors. Using a virtual environment gives you a clean slate:

sh
python -m venv myenv
myenv\Scripts\activate
pip install PySide6
python -c "from PySide6.QtWidgets import QApplication; print('Works!')"

This isolates PySide6 from any other packages that might interfere.

The IDE problem: Spyder, Jupyter, and Qt conflicts

Here's where things get interesting. Both Spyder and Jupyter Notebook are themselves built using Qt. When you launch Spyder, it imports PyQt5 (or PyQt6) as part of starting up its own graphical interface. This happens before your code ever runs.

Qt has a strict rule: you can only use one Qt binding per Python process. If Spyder has already loaded PyQt5, then trying to import PySide6 in the same process will fail. You'll see errors like:

  • ImportError: DLL load failed
  • No module named 'PySide6.QtWidgets'; 'PySide6' is not a package
  • You need one (and only one) QApplication instance per application

These errors aren't really about PySide6 being broken. They're about two different Qt bindings colliding in the same process.

Can you have both PyQt6 and PySide6 installed?

Yes, absolutely. Having both installed side by side is perfectly fine. The restriction is that you can't import both in the same Python process. Since Spyder's process already has PyQt loaded, your PySide6 imports fail within Spyder's console. For more on the differences between the two bindings, see our PyQt6 vs PySide6 comparison.

The QApplication problem

Even if you stick to one binding, there's another wrinkle with IDEs like Spyder and Jupyter. Both run a long-lived Python process (a kernel) that persists between your code executions. Qt applications need exactly one QApplication instance. If you run your GUI code, close the window, and run it again, the old QApplication is still alive in the kernel. The second run then complains that a QApplication already exists.

This makes IDEs with persistent kernels a poor fit for developing Qt GUI applications.

The best way to run PySide6 applications

For GUI development, you want your application to run as its own separate process. This means the Python process starts, runs your app, and exits cleanly when you close the window. There are a few good ways to do this:

Run from the command line

Save your code to a .py file and run it directly:

sh
python my_app.py

This is the most reliable approach and avoids all IDE-related conflicts.

Use PyCharm with "Run" (not the console)

PyCharm runs your script as a separate process when you use the Run button (or press Shift+F10). This works well for GUI development because each run starts fresh. Just avoid typing PySide6 code into PyCharm's interactive Python console — use the Run feature instead. See our getting started with PyCharm guide for more tips.

Use VS Code

VS Code with the Python extension is another excellent choice. When you run a Python file, it launches a new process each time, which keeps things clean.

Spyder: run as an external process

If you prefer Spyder, you can configure it to run scripts in an external terminal rather than its internal console. Go to Run > Configuration per file (or Preferences > Run) and select Execute in an external system terminal. This launches your script as a separate process, avoiding the Qt conflict entirely.

A complete working example

Here's a small PySide6 application you can save to a file and run from the command line or your IDE's Run feature to confirm everything is working:

python
import sys
from PySide6.QtWidgets import (
    QApplication, QMainWindow, QLabel, QVBoxLayout, QWidget
)
from PySide6.QtCore import Qt


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("PySide6 Test")

        label = QLabel("PySide6 is working!")
        label.setAlignment(Qt.AlignmentFlag.AlignCenter)

        layout = QVBoxLayout()
        layout.addWidget(label)

        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)


app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()

Save this as test_pyside6.py and run it:

sh
python test_pyside6.py

You should see a window appear with the text "PySide6 is working!" displayed in the center.

Summary

When you see DLL load failed or other import errors with PySide6, here's how to work through it:

  • Test outside your IDE first. Run a simple import from the command line to rule out IDE conflicts.
  • Reinstall PySide6 if the command-line test also fails. Use a virtual environment for a clean setup.
  • Avoid running Qt GUI code inside Spyder's console or Jupyter Notebook. These environments already use Qt internally, and the resulting conflicts produce misleading error messages.
  • Run your GUI scripts as separate processes — from the command line, using PyCharm's Run button, or by configuring Spyder to use an external terminal.

Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

Fixing "DLL load failed" and Import Errors with PySide6 on Windows was written by Martin Fitzpatrick.

Martin Fitzpatrick is the creator of Python GUIs, and has been developing Python/Qt applications for the past 12+ years. He has written a number of popular Python books and provides Python software development & consulting for teams and startups.