Why do I have "ModuleNotFoundError: No module named 'scipy.special.cython_special'" when I don't even use cython?

Viewed 4158

I used pyinstaller to generate an executable for a python script, and when trying to run the executable I get the error ModuleNotFoundError: No module named 'scipy.special.cython_special'. I'm not sure where this is coming from, or how to fix it. My executable takes in one argument and returns a list. Any help is appreciated!

6 Answers

I had this error after freezing a program that used scipy version 1.5.0 but I changed the version to 1.4.1 (which I had used with an earlier virtual environment) and the error disappeared.

I'm getting the same error, and not exactly sure what causes it or why pyinstaller doesn't find that dependency, but you can fix it by adding 'scipy.special.cython_special' to your pyinstaller myapp.spec file like this:

a = Analysis(['/Users/Name/path/to/mystartupfile.py'],
             pathex=['/Users/Name/...'],
             binaries=[],
             datas=[('data')],
             hiddenimports=['scipy.special.cython_special'],
             hookspath=['/Users/Name..../hooks'],
             runtime_hooks=[],
             excludes=['IPython', 'FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

Add --hidden-import="scipy.special.cython_special" to your pyinstaller command.

I just solved this problem by copying the cython_special.cp37-win_amd64.pyd file from MyEnv>Lib>site-packages>scipy>special into the same directory of the compiled pyinstaller program.

I had the same problem, turns out I was using Python 3.8 which isn't supported by Pyinstaller. Try using 3.7.

Related