scipy: BUG: Pythonw does not run on Windows 11 when scipy.fft is being imported

Describe your issue.

I have developed a small pyw which is using scipy.fft internally. Recently, I have noticed that this small script stops running on Windows 11.

As a workaround, I have tried to redirect stdout and stderr before importing scipy.fft:

if sys.executable.endswith('pythonw.exe'):
    sys.stdout = open(os.devnull, 'w')
    sys.stderr = open(os.path.join(os.getenv('TEMP'), 'stderr-' + os.path.basename(sys.argv[0])), 'w')

If so, the python script works well but no error message is captured.

Reproducing Code Example

import tkinter as tk
from scipy.fft import fft, fftfreq
root = tk.Tk()
root.mainloop()

Error message

Precisely, there is no error message.

SciPy/NumPy/Python version and system information

>>> import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info); scipy.show_config()
1.14.1 2.0.0 sys.version_info(major=3, minor=12, micro=4, releaselevel='final', serial=0)
Build Dependencies:
  blas:
    detection method: pkgconfig
    found: true
    include directory: C:/Users/runneradmin/AppData/Local/Temp/cibw-run-do_lqnow/cp312-win_amd64/build/venv/Lib/site-packages/scipy_openblas32/include
    lib directory: C:/Users/runneradmin/AppData/Local/Temp/cibw-run-do_lqnow/cp312-win_amd64/build/venv/Lib/site-packages/scipy_openblas32/lib
    name: scipy-openblas
    openblas configuration: OpenBLAS 0.3.27.dev DYNAMIC_ARCH NO_AFFINITY Zen MAX_THREADS=24
    pc file directory: D:/a/scipy/scipy
    version: 0.3.27.dev
  lapack:
    detection method: pkgconfig
    found: true
    include directory: C:/Users/runneradmin/AppData/Local/Temp/cibw-run-do_lqnow/cp312-win_amd64/build/venv/Lib/site-packages/scipy_openblas32/include
    lib directory: C:/Users/runneradmin/AppData/Local/Temp/cibw-run-do_lqnow/cp312-win_amd64/build/venv/Lib/site-packages/scipy_openblas32/lib
    name: scipy-openblas
    openblas configuration: OpenBLAS 0.3.27.dev DYNAMIC_ARCH NO_AFFINITY Zen MAX_THREADS=24
    pc file directory: D:/a/scipy/scipy
    version: 0.3.27.dev
  pybind11:
    detection method: config-tool
    include directory: unknown
    name: pybind11
    version: 2.12.0
Compilers:
  c:
    commands: cc
    linker: ld.bfd
    name: gcc
    version: 10.3.0
  c++:
    commands: c++
    linker: ld.bfd
    name: gcc
    version: 10.3.0
  cython:
    commands: cython
    linker: cython
    name: cython
    version: 3.0.11
  fortran:
    commands: gfortran
    linker: ld.bfd
    name: gcc
    version: 10.3.0
  pythran:
    include directory: C:\Users\runneradmin\AppData\Local\Temp\pip-build-env-sf8gymnb\overlay\Lib\site-packages/pythran
    version: 0.16.1
Machine Information:
  build:
    cpu: x86_64
    endian: little
    family: x86_64
    system: windows
  cross-compiled: false
  host:
    cpu: x86_64
    endian: little
    family: x86_64
    system: windows
Python Information:
  path: C:\Users\runneradmin\AppData\Local\Temp\cibw-run-do_lqnow\cp312-win_amd64\build\venv\Scripts\python.exe
  version: '3.12'

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 21 (13 by maintainers)

Most upvoted comments

That PYTHONPATH issue doesn’t seem relevant. It’s not needed when installing scipy in a regular way, e.g. with pip or conda, only when building locally with dev.py.

You only should have to investigate the case where python.exe does work, and pythonw.exe does not.

Works fine, tinker window opens and I have to close it.

That sounds like you cannot reproduce the bug report locally.