过去,我使用pycompiler(或'pyinstaller')来编译我的程序,它使用PyQt4框架来执行代码,只是因为py2exe。
我最近换了电脑,还没有设法编译我的PyQt4程序!使用Pyinstaller编译PyQt4时出现错误
在这台计算机中,我设置了一个环境变量%pycompile%,它具有pyinstaller.py文件的目录。
这是我插入cmd.exe的代码,即使用Python代码NOT IMPORT PYQT4。
python %pycompile% --noconsole myscript.pyw
然而,当我尝试编译我的基于PyQt4的程序,我得到一个语法错误,从试图编译PyQt4的程序时由pyinstaller.py进口Python文件内起源(我的解释)。 “exec_ = EXEC”
E:\ChemCalc ULTIMATE\ChemCalc ULTIMATE>python %pycompile% Penny.pyw
I: skip Configure.py, use existing config C:\Python27\PyCompile\config.dat
wrote E:\ChemCalc ULTIMATE\ChemCalc ULTIMATE\Penny.spec
I: Dependent assemblies of C:\Python27\python.exe:
I: x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none
checking Analysis
building Analysis because outAnalysis0.toc non existent
running Analysis outAnalysis0.toc
Analyzing: C:\Python27\PyCompile\support\_mountzlib.py
Analyzing: C:\Python27\PyCompile\support\useUnicode.py
Analyzing: Penny.pyw
Syntax error in exec_py3.py
('invalid syntax', ('exec_py3.py', 1, 12, 'exec_ = exec\n'))
Traceback (most recent call last):
File "C:\Python27\PyCompile\pyinstaller.py", line 187, in <module>
main(parser)
File "C:\Python27\PyCompile\pyinstaller.py", line 76, in main
run_build(opts, args, spec_file)
File "C:\Python27\PyCompile\pyinstaller.py", line 52, in run_build
Build.main(spec_file, configfilename=opts.configfile)
File "C:\Python27\PyCompile\Build.py", line 1472, in main
build(specfile)
File "C:\Python27\PyCompile\Build.py", line 1429, in build
execfile(spec)
File "E:\ChemCalc ULTIMATE\ChemCalc ULTIMATE\Penny.spec", line 3, in <module>
pathex=['E:\\ChemCalc ULTIMATE\\ChemCalc ULTIMATE'])
File "C:\Python27\PyCompile\Build.py", line 347, in __init__
self.__postinit__()
File "C:\Python27\PyCompile\Build.py", line 298, in __postinit__
self.assemble()
File "C:\Python27\PyCompile\Build.py", line 416, in assemble
analyzer.analyze_script(script)
File "C:\Python27\PyCompile\mf.py", line 572, in analyze_script
return self.analyze_r('__main__')
File "C:\Python27\PyCompile\mf.py", line 466, in analyze_r
newnms = self.analyze_one(name, nm, imptyp, level)
File "C:\Python27\PyCompile\mf.py", line 525, in analyze_one
mod = self.doimport(nm, ctx, fqname)
File "C:\Python27\PyCompile\mf.py", line 587, in doimport
mod = parent.doimport(nm)
File "C:\Python27\PyCompile\mf.py", line 761, in doimport
mod = self.subimporter.getmod(nm)
File "C:\Python27\PyCompile\mf.py", line 355, in getmod
mod = owner.getmod(nm)
File "C:\Python27\PyCompile\mf.py", line 117, in getmod
co = compile(string.replace(stuff, "\r\n", "\n"), py[0], 'exec')
File "exec_py3.py", line 1
exec_ = exec
^
SyntaxError: invalid syntax
我使用,我用我的旧电脑pycompile的相同版本(216)。他们都使用32位Python 2.7.2运行32位Windows。
想要所有帮助!
(我吓坏了,我MASSIVE编程项目不能被编译!)
我读过有关使用PyQt的pyinstaller错误相当多的堆栈问题,但不是我的特定错误!
谢谢!
我的代码开始于:
import sys
import getpass
import hmac
import random
import shutil
from PyQt4 import QtGui, QtCore
from RegMenu import Ui_RegristrationMenu
from ChemWindow import Ui_ChemWindow
from ReactionClass import ReactionElement
from StoichUnitSelectionClass import Ui_StoichUnitSelection
from VisualTool import Ui_Aesthetics_Tool
import decimal
import sympy
import math
和结尾为:
sys.exit(ApplicationRun.exec_())
蟒2.7.2(32位)
pycompile构建(216)
PyQt4中(4.5 )
Windows 7(32位)
也许你可以尝试一些替代?我正在使用[cx_Freeze](http://cx-freeze.sourceforge.net/)。 – reclosedev
我怀疑这件事有关:http://code.google.com/p/mpmath/issues/detail?id=204 – Avaris
通过使用紧张的黑客Avaris链接来修复它(pyinstaller)。谢谢! –