Sauravroy34
(Saurav Kumar Roy)
January 17, 2026, 5:13pm
2
HI,There
i guess this github issue should be relevant
opened 10:14AM - 30 Oct 25 UTC
module: binaries
module: windows
triaged
### 🐛 Describe the bug
## PyTorch fails to import after PyQt on Windows
### De… scription
Importing PyTorch **after** PyQt on Windows causes a DLL initialization error. The same code works if PyTorch is imported first.
This issue started occurring after upgrading from PyTorch `2.8.0` to `2.9.0`.
## Reproduction
### This code fails:
```python
from PyQt6.QtWidgets import QApplication
import torch
```
**Result:**
```bash
Traceback (most recent call last):
File ""C:\...\abogen\abogen\test.py", line 3, in <module>
import torch
File ""C:\...\Lib\site-packages\torch\__init__.py", line 281, in <module>
_load_dll_libraries()
File ""C:\...\Lib\site-packages\torch\__init__.py", line 264, in _load_dll_libraries
raise err
OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed. Error loading ""C:\...\Lib\site-packages\torch\lib\c10.dll" or one of its dependencies.
```
### This code works:
```python
import torch
from PyQt6.QtWidgets import QApplication
```
**Result:**
```
(imports successfully, no error)
```
### Notes
- Issue started after upgrading from PyTorch `2.8.0` to `2.9.0`.
- Affects Windows GUI applications using both PyTorch and PyQt
> [!NOTE]
> Issue is still present in PyTorch `2.9.1`
### Versions
Collecting environment information...
PyTorch version: 2.9.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: Microsoft Windows 11 Home (10.0.26200 64-bit)
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A
Python version: 3.12.12 [MSC v.1944 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-11-10.0.26200-SP0
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Versions of relevant libraries:
[pip3] intel-openmp==2021.4.0
[pip3] mkl==2021.4.0
[pip3] numpy==2.3.4
[pip3] tbb==2021.13.1
[pip3] torch==2.9.0
[pip3] torchaudio==2.9.0
[pip3] torchvision==0.24.0
[conda] Could not collect
cc @seemethere @malfet @atalman @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex
this comment might be helpfull
(temporary solution)try adding these lines before importing pytorch see if it works
import os
import platform
if platform.system() == “Windows”:
import ctypes
from importlib.util import find_spec
try:
if (spec := find_spec(“torch”)) and spec.origin and os.path.exists(
dll_path := os.path.join(os.path.dirname(spec.origin), “lib”, “c10.dll”)
):
ctypes.CDLL(os.path.normpath(dll_path))
except Exception: