MPA
MPA

Reputation: 2038

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?

Upvotes: 2

Views: 3313

Answers (1)

marius_cornescu
marius_cornescu

Reputation: 76

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 hooks 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.

Upvotes: 1

Related Questions