简体   繁体   中英

Using PyInstaller (console, onefile) on a .py file that includes statsmodels

When I run the .exe , it generates the following in the console output:

C:\\Python27\\Scripts\\dist>SNAPpy279.exe

Traceback (most recent call last): File "<string>", line 26, in <module> File "C:\\Python27\\Lib\\site-packages\\PyInstaller\\loader\\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\\Python27\\Scripts\\build\\SNAPpy279\\out00-PYZ.pyz\\statsmodels.api", line 19, in <module> File "C:\\Python27\\Lib\\site-packages\\PyInstaller\\loader\\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__) File "C:\\Python27\\Scripts\\build\\SNAPpy279\\out00-PYZ.pyz\\statsmodels.__init__", line 8, in <module> ImportError: No module named tools.sm_exceptions

Any potentially easy solutions for this? Suggestions?

UPDATE: Ran into this once again and my fix did not work. To solve it, I changed the line
from .tools.sm_exceptions import (ConvergenceWarning, CacheWriteWarning, IterationLimitWarning, InvalidTestWarning)
In \\statsmodels\\__init__.py at line 8 to :
from statsmodels.tools.sm_exceptions import (ConvergenceWarning, CacheWriteWarning, IterationLimitWarning, InvalidTestWarning)


I think I ran in the same issue last week. In my case, I fixed it by adding
import statsmodels.api
in my main script.
The import was done within another module previously.

Hoping this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM