简体   繁体   中英

Including python modules for PyInstaller?

In one of my first attempts to package my python code into a .exe file, I experience issues with packaging and running code using the scipy.weave module. When I check my warnproject.txt, I see 1324 lines of warnings (a couple of lines included below)

W: no module named numpy.negative (top-level import by scipy.weave.size_check)
W: no module named numpy.asarray (top-level import by scipy.optimize.nonlin)
W: no module named termios (top-level import by tty)
W: no module named scipy.arange (conditional import by scipy.sparse.linalg.isolve.minres)
W: no module named numpy.polyder (top-level import by scipy.signal.signaltools)
W: no module named matplotlib.rcParams (top-level import by matplotlib.figure)
etc...

First question: why do I get this many warnings whereas the program partially runs ok?

Second question: how do I import these modules in a correct manner? In my project.spec file I have written exe = EXE(..., a.binaries + [('scipy.weave', 'C:\\Python27\\Lib\\site-packages', 'PYMODULE')], ...) but it can't find the module and will not package any file?

One way to go is using the hooks option for the Analysis object. This forces the Analysis (the guy who compiles the list of dependencies among others) to consider that the modules from hooks have been imported, so are required.

a = Analysis(['myscript.py'], hookspath='/my/priv/hooks')

The file is simple text file. 文件是简单的文本文件。

On the other hand, I have tons of such warnings, and my application runs on linux and windows without import related issues.

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