试图将Python脚本转换为Windows executab时,cxfreeze在oauthlib中生成SyntaxError异常

2024-05-20 10:10:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用cxfreeze将python3.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。思想?在


Tags: inpyfinderpackageslinesitenamespacefile