编辑2017年9月2日下午1点
我最终设法使用pyinstaller在许多情节之后build立一个.exe。
不幸的是,我没有处理'theano'模块(在我的情况下'pymc3'模块需要这个模块),我不得不修改.py文件并放弃部分应用程序。 我在下面的描述有两个目的:首先它可能有帮助; 其次,任何人都可以帮助我build立一个.exe的Windows 7 +,'theano'模块?
提醒:我的python 3脚本在'.ui'文件中打开一个简单的用Qt Designer创build的GUI,并导入pyqtgraph(与pyqt5),pymc3(以及pymc3需要的theano),scipy,numpy,os,sys。 它将分布在Windows 7 +的机器上。 我试图用py2exe,cx_freeze,pynsist和pyinstallerbuild立'.exe'(我打开并更新了几个post,这个仍然是打开的: 从python 3脚本导入pyqtgraph并打开一个GUI为Windows生成一个.exe文件 ),但全部失败。 我最好的结果(与pyinstaller)下面描述后,我不得不放弃theano。
pyinstaller —noupx —onefile —add-data “toto.ui;.” toto.py
。 但奇怪的是: 1 qtdevise器文件“toto.ui”不包含在内,必须与.exe一起发布。 否则在运行.exe文件时会出现错误信息,说toto.ui没有find;
2 python环境的“Library / plugin”目录中的“platforms”目录也必须与.exe一起分发。 否则当运行.exe“这个应用程序启动失败,因为找不到qt平台插件窗口”(但是没有错误信息从pyinstallerbuild立的时候)出现错误信息!
3 .exe是220MB大! 似乎pyinstaller在build设过程中包含了一堆无用的东西。
乍一看,模块“pyqtgraph”似乎与pyinstaller不兼容。 事实上,当python代码导入pyqtgraph时,pyinstaller会'yield' inside async function
给出一个SyntaxError: 'yield' inside async function
。 这在我看来非常尴尬(这是pyinstaller中的一个错误?),因为我对论坛有印象,这与只与python 3.6兼容的asynchronous生成器有关,而pyinstaller只与python 3.5一起工作 – 这与asynchronous不兼容生成器…为什么pyinstaller使用这个? 事实certificate,这个类似bug的function在一个新版本的pyinstaller中是被禁用的,而这个新版本没有被发布(默认情况下没有安装): pip install git+https://github.com/pyinstaller/pyinstaller
,感谢9dogs(in注释)。 我也发现它可能有助于明确地写入py.txt文件之前导入py文件os.environ ['PYQTGRAPH_QT_LIB'] ='PyQt5'或'PyQt4'
theano原来做了几个隐式导入,没有被pyinstaller检测到。 因此,build筑物看起来不错,但运行.exe时,你会得到像“no module theano.tensor.shared_randomstreams”这样的错误消息。 不幸的是,我没有使用pyinstaller的' – hidden-import'选项,所以我明确添加了py文件中的导入(在这个例子中'import theano.tensor.shared_randomstreams')。
但是,这不是结束:之后,文件'… \ AppData \ Local \ Temp_MEI35682 \ theano \ gpuarray \ blockgemv.c'丢失,导致[4128] Failed to execute script
。 我不知道这个文件是什么,也没有find信息。 我放弃了并删除了一部分GUI以避免theano。 任何人都可以帮助我与pyinstaller使用theano?