2013-07-26 3 views
2

Je vais avoir un problème similaire au poste:PyInstaller et PySide et QtGui

Pyinstaller: ImportError: cannot import name QtGui

... mais ce poste ne semble pas avoir une solution. Je ne peux pas utiliser pyinstaller pour installer le très simplement le script 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() 

je lance:

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

qui génère:

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 

Ce produit avec succès un exécutable, mais quand je l'exécute, je reçois la sortie suivante:

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

Mon système est Linux Mint 15 (ubuntu 13.04), PySide et PySide-dev sont installés et utilisés un peu, j'utilise pyinstaller 2.0.

Toute aide serait très appréciée.

Derek

+0

Je ne pas eu de problème d'emballage applications pyside avec [** cx_Freeze **] (http: // cx-gel. sourceforge.net/). –

Répondre

0

Ceci est probablement lié aux importations cachées que l'analyse ne peut pas détecter. A partir du manuel:

Si l'analyse pense qu'il a trouvé toutes les importations, mais l'application échoue avec une erreur d'importation, le problème est une importation cachée; c'est-à-dire une importation qui n'est pas visible pour la phase d'analyse. Les importations cachées peuvent se produire lorsque le code utilise importer ou peut-être exec ou eval. Vous en obtenir des avertissements (voir Messages de compilation). Les importations masquées peuvent également se produire lorsqu'un module d'extension utilise l'API Python/C pour effectuer une importation . Lorsque cela se produit, l'analyse ne peut rien détecter. Il y aura aucun avertissement, seulement un plantage à l'exécution. Pour trouver ces importations cachées, définissez l'indicateur -v (Obtenir les importations verbales de Python ci-dessus). Une fois que vous savez ce qu'ils sont, vous ajoutez les modules nécessaires à l'ensemble en utilisant l'option de commande --hidden-import =, en éditant le fichier spec, ou avec un fichier hook (voir Utilisation des fichiers Hook ci-dessous).

Essayez d'ajouter ce qui suit à la section Analyse de votre fichier de spécification:

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

J'ai le même problème et l'ajout des importations cachées n'aide pas. –

Questions connexes