我正在尝试使用cxfreeze
将Python 3.2.2程序转换为Windows可执行文件。我编写的“getstats.py
”程序从编译器和命令行运行得很好。当我在Windows命令行上运行cxfreeze src\getstats.py
进行编译时,我会得到一长串异常,最终导致SyntaxError: invalid syntax
异常:
Traceback (most recent call last):
File "C:\Python32\Scripts\cxfreeze", line 5, in <module>
main()
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\main.py", line 188, in main
freezer.Freeze()
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\freezer.py", line 470, in Freeze
self._FreezeExecutable(executable)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\freezer.py", line 144, in _FreezeExecutable
scriptModule = finder.IncludeFile(exe.script, exe.moduleName)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 492, in IncludeFile
deferredImports)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 352, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 440, in _ScanCode
module, relativeImportIndex)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 218, in _ImportModule
deferredImports, namespace = namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 305, in _InternalImportModule
parentModule, namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 317, in _LoadModule
namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 362, in _LoadPackage
self._LoadModule(name, fp, path, info, deferredImports, parent)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 352, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 440, in _ScanCode
module, relativeImportIndex)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 254, in _ImportModule
deferredImports, namespace = namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 305, in _InternalImportModule
parentModule, namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 352, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 440, in _ScanCode
module, relativeImportIndex)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 254, in _ImportModule
deferredImports, namespace = namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 305, in _InternalImportModule
parentModule, namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 352, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 440, in _ScanCode
module, relativeImportIndex)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 218, in _ImportModule
deferredImports, namespace = namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 289, in _InternalImportModule
namespace = namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 305, in _InternalImportModule
parentModule, namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 317, in _LoadModule
namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 362, in _LoadPackage
self._LoadModule(name, fp, path, info, deferredImports, parent)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 352, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 440, in _ScanCode
module, relativeImportIndex)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 254, in _ImportModule
deferredImports, namespace = namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 305, in _InternalImportModule
parentModule, namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 317, in _LoadModule
namespace)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 362, in _LoadPackage
self._LoadModule(name, fp, path, info, deferredImports, parent)
File "C:\MyPython\Python\Python32\site-packages\cx_Freeze\finder.py", line 330, in _LoadModule
module.code = compile(codeString, path, "exec")
File "C:\MyPython\Python\Python32\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 18
SIGNATURE_HMAC = u"HMAC-SHA1"
SyntaxError: invalid syntax
这是我第一次尝试使用cxfreeze
,所以我不确定这里可能会有什么问题。该程序中唯一使用的“非标准”模块是requests
。想法?