2013-07-26 192 views
2

我有一個類似的問題的帖子:PyInstaller和PySide和QtGui

Pyinstaller: ImportError: cannot import name QtGui

...但是這個職位似乎並不有一個解決辦法。我不能用pyinstaller安裝非常簡單地PySide腳本(helloWorld.py):

#!/usr/bin/python 
import sys 
from PySide import QtGui 
from PySide import QtCore 
app = QtGui.QApplication(sys.argv) 
label = QtGui.QLabel("Hello Plain World") 
label.show() 
app.exec_() 
sys.exit() 

我運行:

]$ ./makespec.py -F helloWorld.py 
]$ pyinstaller helloWorld.Spec 

產生:

fatal: Not a git repository (or any of the parent directories): .git 
20 INFO: UPX is not available. 
34 INFO: Processing hook hook-os 
103 INFO: Processing hook hook-time 
104 INFO: Processing hook hook-cPickle 
156 INFO: Processing hook hook-_sre 
245 INFO: Processing hook hook-cStringIO 
308 INFO: Processing hook hook-encodings 
316 INFO: Processing hook hook-codecs 
599 INFO: Extending PYTHONPATH with /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/tmp 
599 INFO: checking Analysis 
599 INFO: building Analysis because out00-Analysis.toc non existent 
599 INFO: running Analysis out00-Analysis.toc 
632 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /_pyi_bootstrap.py 
643 INFO: Processing hook hook-os 
652 INFO: Processing hook hook-site 
661 INFO: Processing hook hook-encodings 
726 INFO: Processing hook hook-time 
727 INFO: Processing hook hook-cPickle 
780 INFO: Processing hook hook-_sre 
871 INFO: Processing hook hook-cStringIO 
939 INFO: Processing hook hook-codecs 
1272 INFO: Processing hook hook-pydoc 
1358 INFO: Processing hook hook-email 
1398 INFO: Processing hook hook-httplib 
1430 INFO: Processing hook hook-email.message 
1476 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /pyi_importers.py 
1515 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /pyi_archive.py 
1542 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /pyi_carchive.py 
1570 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /pyi_os_path.py 
1573 INFO: Analyzing helloWorld.py 
1575 INFO: Processing hook hook-PySide 
1575 INFO: Hidden import 'codecs' has been found otherwise 
1575 INFO: Hidden import 'encodings' has been found otherwise 
1575 INFO: Looking for run-time hooks 
objdump: section '.dynamic' mentioned in a -j option, but not found in any input file 
2579 INFO: Using Python library /usr/lib/libpython2.7.so.1.0 
2579 INFO: Adding Python library to binary dependencies 
2964 INFO: Warnings written to /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/tmp/build /helloWorld/warnhelloWorld.txt 
2968 INFO: checking PYZ 
2968 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing 
2968 INFO: building PYZ (ZlibArchive) out00-PYZ.toc 
3329 INFO: checking PKG 
3329 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing 
3329 INFO: building PKG (CArchive) out00-PKG.pkg 
objdump: section '.dynamic' mentioned in a -j option, but not found in any input file 
10614 INFO: checking EXE 
10614 INFO: rebuilding out00-EXE.toc because helloWorld missing 
10614 INFO: building EXE from out00-EXE.toc 
10614 INFO: Appending archive to EXE /home/derek/BitBucketRepos/tmp/qvt/pyinstaller  /tmp/dist/helloWorld 

這成功地產生一個可執行文件,但當我運行它時,我得到以下輸出:

Traceback (most recent call last): 
File "<string>", line 4, in <module> 
ImportError: cannot import name QtGui 

我的系統是Linux Mint 15(ubuntu 13.04),安裝了PySide和PySide-dev並使用了相當多的東西,我使用的是pyinstaller 2.0。

任何幫助將大大appricated。

Derek

+0

我沒有包裝PySide應用與任何麻煩[** cx_Freeze **](HTTP:// CX-凍結。 sourceforge.net/)。 –

回答

0

這可能與分析無法檢測到的隱藏導入有關。從手冊:

如果Analysis認爲它已經找到所有導入,但該應用失敗 帶有導入錯誤,則問題是隱藏導入;即分析階段不可見的 導入。當代碼使用導入或者可能是exec或eval時,隱藏導入可能會出現 。您 會收到這些警告(請參閱生成時間消息)。當擴展模塊使用Python/C API執行 導入時,隱藏導入也會出現 。發生這種情況時,Analysis可以檢測到任何東西將會有 沒有警告,只有在運行時崩潰。要找到這些隱藏的導入, 設置-v標誌(上面的獲取Python的詳細導入)。一旦你知道它們是什麼,你可以使用 --hidden-import =命令選項,通過編輯規格文件或鉤子文件(參見下面的使用鉤子文件)將所需的模塊添加到軟件包中。

嘗試添加以下到您的規範文件的分析部分:

hiddenimports=['PySide.QtCore','PySide.QtGui'] 
+0

我有同樣的問題,並添加隱藏的進口沒有幫助。 –