简体   繁体   English

包括用于PyInstaller的python模块吗?

[英]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. 在将python代码打包为.exe文件的第一次尝试中,我遇到了使用scipy.weave模块打包和运行代码的scipy.weave When I check my warnproject.txt, I see 1324 lines of warnings (a couple of lines included below) 当我检查warnproject.txt时,我看到1324行警告(下面​​包含几行)

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? 在我的project.spec文件中,我写了exe = EXE(..., a.binaries + [('scipy.weave', 'C:\\Python27\\Lib\\site-packages', 'PYMODULE')], ...)但找不到模块,也不会打包任何文件?

One way to go is using the hooks option for the Analysis object. 一种方法是对Analysis对象使用hooks选项。 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. 这迫使Analysis(负责编译依赖关系列表的人员)考虑已从钩子中导入了模块,因此是必需的。

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. 另一方面,我有很多这样的警告,并且我的应用程序可以在linux和Windows上运行,而没有导入相关的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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