简体   繁体   English

Py2exe无法将python脚本转换为Windows可执行文件

[英]Py2exe cannot be convert python script to Windows executables

I want to make the python script into Windows executable with py2exe. 我想用py2exe将python脚本制作成Windows可执行文件。 I did not miss MSVCP90.dll and the Feiwings.py(the file that I use for transforming) and setup.py are under the same path. 我没有错过MSVCP90.dll和Feiwings.py(用于转换的文件)和setup.py在同一路径下。 Doing those things under command window, everything works fine, the last lines of the traceback here are: 在命令窗口下执行这些操作,一切正常,回溯的最后几行是:

**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

The setup.py has the content like this: setup.py的内容如下:

from distutils.core import setup
import py2exe

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

When I cd the path to dist directory, it got an error. 当我对dist目录的路径进行cd时,出现错误。

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

Thanks in advance! 提前致谢!

It seems something is wrong in your PySide distribution. 您的PySide发行版似乎出了点问题。 From the traceback, it shows a problem in the second line of your Feiwings program. 从追溯开始,它在Feiwings程序的第二行显示了一个问题。 In this line there is probably an import statement where you import something from PySide, right? 在这一行中,可能有一个import语句,您可以在其中从PySide导入某些内容,对吗?

Apart from the py2exe problem, are you able to execute your code normally without raising the same error? 除了py2exe问题外,您还能正常执行代码而不会引发相同错误吗? If so, I would guess that you should include other packages dependencies (eg.: PySide) in your setup, something similar to: 如果是这样,我猜您应该在设置中包括其他软件包依赖项(例如:PySide),类似于:

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

Hope it helps! 希望能帮助到你!

Check the variable 'path' in the program. 检查程序中的变量“路径”。 It seems not a error of Pyside(assuming that you have properly installed Pyside) but the way you have used the variable 'path'. 似乎不是Pyside的错误(假设您已正确安装Pyside),而是使用变量'path'的方式。 Having a look at the error it seems you have used variable 'path' before assigning it any value. 看一下错误,似乎您在分配变量任何值之前都使用了变量“ path”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM