2014-12-09 122 views
0

我想用py2exe將python腳本轉換爲Windows可執行文件。我沒有錯過MSVCP90.dll和Feiwings.py(我用於轉換的文件)和setup.py在相同的路徑下。在命令窗口中做的那些事,一切正常,這裏的回溯的最後一行是:Py2exe不能將python腳本轉換爲Windows可執行文件

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

在此先感謝!

回答

0

你的PySide發行版似乎有些問題。從回溯來看,它顯示了飛翼計劃第二行的一個問題。在這一行中,可能會有一個導入語句,您可以從PySide導入某些內容,對吧?

除了py2exe的問題,你是否能夠正常執行你的代碼而不會引發同樣的錯誤? 如果是的話,我猜你應該包括其他軟件包的依賴(如:PySide)在你的設置,類似於:

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

希望它能幫助!

0

檢查程序中的變量'path'。這似乎不是Pyside的錯誤(假設你已經正確安裝了Pyside),而是你使用變量'path'的方式。看看這個錯誤,看起來你已經在賦值之前使用了變量'path'。