【问题标题】:Py2exe cannot be convert python script to Windows executablesPy2exe 无法将 python 脚本转换为 Windows 可执行文件
【发布时间】:2014-12-09 12:59:59
【问题描述】:

我想用 py2exe 将 python 脚本变成 Windows 可执行文件。我没有错过 MSVCP90.dll 和 Feiwings.py(我用于转换的文件)和 setup.py 在同一路径下。在命令窗口下做这些事情,一切正常,这里回溯的最后几行是:

**binary dependencies****
your executable(s) also depend on these dlls which are not included. You may or may not need to distribute them.
Make sure you have the license if you distribute any of them, and make sure you don't distribute files belonging to the operating system.
USER32.dll -C:\WINDOWS\system32\USER32.dll
SHELL32.dll -C:\WINDOWS\system32\SHELL32.dll
ADVAPI32.dll -C:\WINDOWS\system32\ADVAPI32.dll
WS2_32.dll -C:\WINDOWS\system32\WS2_32.dll
GDI32.dll -C:\WINDOWS\system32\GDI32.dll
KERNEL32.dll -C:\WINDOWS\system32\KERNEL32.dll

setup.py 的内容如下:

from distutils.core import setup
import py2exe

setup(console=['D:\python\Feiwings.py'])

当我 cd 到 dist 目录的路径时,它出错了。

Traceback (most recent call last):
  File "Feiwings.py", line 2, in <module>
  File "PySide\__init__.pyc", line 45, in <module>
  File "PySide\__init__.pyc", line 43, in _setupQtDirectories
UnboundLocalError: local variable 'path' referenced before assignment

提前致谢!

【问题讨论】:

    标签: python python-2.7 pyside py2exe


    【解决方案1】:

    您的 PySide 发行版似乎有问题。从traceback看,你的飞翼程序第二行有问题。在这一行中,可能有一个 import 语句,您可以从 PySide 导入一些东西,对吧?

    除了py2exe的问题,你能正常执行你的代码而不会出现同样的错误吗? 如果是这样,我猜你应该在你的设置中包含其他包依赖项(例如:PySide),类似于:

    setup(packages=['PySide'],
          console=['D:\python\Feiwings.py'])
    

    希望对你有帮助!

    【讨论】:

      【解决方案2】:

      检查程序中的变量“路径”。这似乎不是 Pyside 的错误(假设您已正确安装 Pyside),而是您使用变量“路径”的方式。查看错误,您似乎在为其分配任何值之前使用了变量“路径”。

      【讨论】:

        猜你喜欢
        • 2019-04-07
        • 1970-01-01
        • 2013-10-26
        • 1970-01-01
        • 2016-05-15
        • 1970-01-01
        • 2014-08-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多