-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
scipy stats module report name 'obj' not defined
Context information (for bug reports)
-
Output of
pyinstaller --version:6.0.0 -
Version of Python: 3.12.0
-
Platform: Windows (zh-CN)
-
How you installed Python: conda
-
Did you also try this on another platform? Does it work there?: have tried ubuntu22.04, the same error reported
- start with clean installation
- use the latest development version
- Run your frozen program from a command window (shell) — instead of double-clicking on it
- Package your program in --onedir mode
- Package without UPX, say: use the option
--noupxor setupx=Falsein your .spec-file - Repackage you application in verbose/debug mode. For this, pass the option
--debugtopyi-makespecorpyinstalleror useEXE(..., debug=1, ...)in your .spec file.
A minimal example program which shows the error
from scipy.stats import weibull_min
if __name__ == '__main__':
cc = weibull_min(c=2.5, loc=0, scale=1)
print(cc.cdf(0.001))Stacktrace / full error message
Traceback (most recent call last):
File "main.pyw", line 15, in <module>
File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "scipy\stats\__init__.py", line 608, in <module>
File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "scipy\stats\_stats_py.py", line 46, in <module>
File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "scipy\stats\distributions.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
File "scipy\stats\_distn_infrastructure.py", line 360, in <module>
NameError: name 'obj' is not defined
[26600] Failed to execute script 'main' due to unhandled exception!
I read the source code in scipy, the 'obj' located at scipy.stats._distn_infrastructure.py line 360. 'obj' is not defined before but only in some comprehensive list.
It totally ok when python vesion=3.11, but when i change to python 3.12, it report error. I was wondering if its a python 3.12 import system problem. Seems pyinstaller + python 3.11 won't import this 'del obj', but pyinstaller + python 3.12 will do.
# clean up all the separate docstring elements, we do not need them anymore
for obj in [s for s in dir() if s.startswith('_doc_')]:
exec('del ' + obj)
del obj