scipy: BUG: ImportError: DLL load failed while importing _ufuncs: %1 is not a valid Win32 applic

Describe your issue.

Python Version: Python 3.11.2 OS: Windows 11 SciPy version: 1.10.0 Distribution: pip (Conda not installed on the system) Environment: Isolated virtual environment with no deps on host python.

I get the import DLL error every time I execute my python code. This issue started when I re-formatted my laptop and installed the latest SciPy and Python version. If I pip uninstall SciPy, I can execute my code once. As soon as my second execution takes place, I get the same error again.

My best guess is there is an issue with version compatibility. Are there any issues that could be impacting this?

Reproducing Code Example

import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate           # Error here
x = np.arange(0, 10)
y = np.exp(-x/3.0)
f = interpolate.interp1d(x, y)

Error message

Traceback (most recent call last):
  File "E:\test_proj\doubleIntegration.py", line 4, in <module>
    from scipy.interpolate import interp1d
  File "E:\test_proj\venv\Lib\site-packages\scipy\interpolate\__init__.py", line 167, in <module>
  File "E:\test_proj\venv\Lib\site-packages\scipy\interpolate\_interpolate.py", line 8, in <module>                    import scipy.special as spec
  File "E:\test_proj\venv\Lib\site-packages\scipy\special\__init__.py", line 663, in <module>                        from . import _ufuncs
ImportError: DLL load failed while importing _ufuncs: %1 is not a valid Win32 application.

SciPy/NumPy/Python version information

1.10.0 1.24.2 sys.version_info(major=3, minor=11, micro=2, releaselevel=‘final’, serial=0)

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 27 (21 by maintainers)

Most upvoted comments

After installing the MSYS2, and performing a few times pacman -Syu. After that, I install pacman -S mingw-w64-x86_64-gcc-fortran and other dependencies I don’t quite remember all of them. Then I’m adding the bin folder of the MSYS2 on the path and aggressively praying to all deities above and below.