简体   繁体   中英

Error using PyInstaller

I'm trying to use PyInstaller to create a standalone OSX app that runs a GUI I've made. When I enter the following in my terminal:

pyinstaller gui.py

Everything seems to work until I get the following error:

File "/Users/username/anaconda/bin/PyInstaller", line 11, in <module>
    sys.exit(run())
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/build_main.py", line 788, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), 
kw.get('clean_build'))
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/build_main.py", line 734, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/build_main.py", line 212, in __init__
self.__postinit__()
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/datastruct.py", line 178, in __postinit__
self.assemble()
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/build_main.py", line 470, in assemble
module_hook.post_graph()
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/imphook.py", line 409, in post_graph
self._load_hook_module()
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/building/imphook.py", line 376, in 
_load_hook_module
self.hook_module_name, self.hook_filename)
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/hooks/hook-PyQt4.py", line 33, in <module>
(qt_menu_nib_dir('PyQt4'), ''),
File "/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/utils/hooks/qt.py", line 125, in qt_menu_nib_dir
""".format(namespace, path))

Exception: 
            Cannot find qt_menu.nib for PyQt4
            Path checked: 
   /Users/felipe/miniconda/envs/_build/lib/QtGui.framework/Resources/qt_menu.nib

Which seems strange, since my name is not felipe!

I have a couple of questions:

1) How is it possible that there is a directory under the name felipe on my computer? (I used anaconda to install qt, I don't know whether that has something to do with it?)

2) Up until I get the error message, PyInstaller is looking in the correct folder. Why does it start looking in this vague (vague to me that is) directory I don't know of?

3) I'm quite a novice regarding directories and I can't find mister felipe anywhere on my computer. When I look in the Users folder I just see my own user and an empty "Shared" folder. (I don't know what the shared folder is used for and why it's there.)

4) Based on what I read on the internet, I copied qt_menu-nib to the folder where the script that's supposed to be turned into a standalone is located. What should I do in order to successfully create a standalone from here?

First of all, you face a known issue between PyInstaller and Anaconda: PyInstaller issue #2135 . The conversation contains answers to your questions.

1) The path is hardcoded in the wrongly built Qt binary that is provided by Anaconda, see comment from mrady3 .

2) PyInstaller loads Qt4-specific hook in order to find resources ( qt_menu.nib ) that are necessary for running target app. The hook code tries to obtain location of resource directory from the Qt binary itself. Qt binary returns wrong /hardcoded/ path, and after that process fails.

3) See point 1), it was a folder on maintainer's machine. Qt assumes that its installation path is pre-set before building; Anaconda repository hosts a binary that was compiled with another installation path in mind.

4) There could be several possible approaches:

Try installing developer version of PyInstaller from sources, it has some fixes for the above-mentioned issue . Then try building the app again:

git clone https://github.com/pyinstaller/pyinstaller.git
cd pyinstaller
/Users/username/anaconda/bin/python setup.py sdist
conda install dist/PyInstaller-3.3.dev0.tar.bz2

Install Qt4 using homebrew . Local compilation will take a long time:

brew install cartr/qt4/qt
find /usr/local/Cellar/qt -name qt_menu.nib

Edit Qt4 hook at /Users/username/anaconda/lib/python2.7/site- packages/PyInstaller/hooks/hook-PyQt4.py and replace call to qt_menu_nib_dir('PyQt4') with the path from homebrew installation ( '/usr/local/Cellar/qt/4.8.7_3/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib' ).

Or alternatively, just put qt_menu.nib into expected location:

sudo mkdir -p /Users/felipe/miniconda/envs/_build/lib/QtGui.framework/Resources/
sudo ln -s /usr/local/Cellar/qt/4.8.7_3/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib /Users/felipe/miniconda/envs/_build/lib/QtGui.framework/Resources/

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