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!
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.
I also had this issue.
Downgrading scipy
package to 1.4.1 solved the issue as @profTC said.
Alternatively, one can upgrade to PyInstaller
4.0 where they have added a new hook file to deal with this. See: https://pyinstaller.readthedocs.io/en/v4.0/CHANGES.html#hooks
Another solution is to use to directly copy the hook file and include it as an additional hook when building with PyInstaller.
© 2022 - 2024 — McMap. All rights reserved.
scipy
package, which is missing the dependencycython_special
. I don't know anything about pyinstaller, but my intuition says that the generated executable does not havescipy
and it's related dependencies correctly bundled. – Shirrscipy
.scipy
usescython
a lot to interface python with compiled packages. You may need to install a fuller 'development' version ofscipy
(and other packages). – Olympias