简体   繁体   中英

Py2exe cannot be convert python script to Windows executables

I want to make the python script into Windows executable with py2exe. 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. 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:

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.

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. From the traceback, it shows a problem in the second line of your Feiwings program. In this line there is probably an import statement where you import something from PySide, right?

Apart from the py2exe problem, are you able to execute your code normally without raising the same error? If so, I would guess that you should include other packages dependencies (eg.: PySide) in your setup, something similar to:

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'. Having a look at the error it seems you have used variable 'path' before assigning it any value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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