2

I'm having a similar problem to the post:

Pyinstaller: ImportError: cannot import name QtGui

... however this post does not appear to have a solution. I cannot use pyinstaller to install the very simply PySide script (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()

I run:

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

which generates:

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

This successfully produces an executable but when I run it I get the following output:

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

My system is Linux Mint 15 (ubuntu 13.04), have PySide and PySide-dev installed and used quite a bit, I am using pyinstaller 2.0.

Any help would be GREATLY appricated.

Derek

Community
  • 1
  • 1
dmon
  • 1,344
  • 1
  • 14
  • 29
  • I didn't have any trouble packaging PySide applications with [**cx_Freeze**](http://cx-freeze.sourceforge.net/). – Oleh Prypin Jul 26 '13 at 21:22

1 Answers1

0

This is likely related to hidden imports that the analysis cannot detect. From the manual:

If Analysis thinks it has found all the imports, but the app fails with an import error, the problem is a hidden import; that is, an import that is not visible to the analysis phase. Hidden imports can occur when the code is using import or perhaps exec or eval. You get warnings of these (see Build-time Messages). Hidden imports can also occur when an extension module uses the Python/C API to do an import. When this occurs, Analysis can detect nothing. There will be no warnings, only a crash at run-time. To find these hidden imports, set the -v flag (Getting Python's Verbose Imports above). Once you know what they are, you add the needed modules to the bundle using the --hidden-import= command option, by editing the spec file, or with a hook file (see Using Hook Files below).

Try adding the following to your spec file's Analysis section:

hiddenimports=['PySide.QtCore','PySide.QtGui']
mr.freeze
  • 13,731
  • 5
  • 36
  • 42