Error using PyInstaller

I am trying to use PyInstaller to create a standalone OSX application that launches the GUI that I created. When I enter the terminal:

pyinstaller gui.py 

Everything works until the following error occurs:

 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 on my computer there is a directory called felipe? (I used anaconda to install qt, I don't know if this has anything to do with this?)

2) Before receiving the error message, PyInstaller searches for the desired folder. Why is it starting to look in this indefinite (foggy for me that is) directory that I don’t know about?

3) I am new to directories and I cannot find Mr. Felipe anywhere on my computer. When I look in the Users folder, I just see my user and the empty Shared folder. (I do not know what the shared folder is used for and why it is there.)

4) Based on what I read on the Internet, I copied qt_menu-nib to the folder where the script is located, which should be turned into a standalone one. What should I do to successfully create a standalone from here?

+5
source share
1 answer

First of all, you encountered a known problem between PyInstaller and Anaconda: Problem with PyInstaller # 2135 . The conversation contains answers to your questions.

1) The path is hardcoded in the erroneously constructed Qt binary provided by Anaconda, see comment from mrady3 .

2) PyInstaller loads the Qt4 binding to find the resources ( qt_menu.nib ) needed to run the target application. The hook code tries to get the location of the resource directory from the Qt bean itself. Qt returns an invalid / hardcoded / path, and after that the process terminates with an error.

3) See point 1), it was a folder on a supporting machine. Qt assumes its installation path is pre-installed before assembly; The Anaconda repository contains a binary file that was compiled using a different installation path.

4) There may be several possible approaches:

Try installing the PyInstaller version of the developer from sources, some fixes for the above problem . Then try creating the application 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 with homebrew . Local compilation will take a lot of time:

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

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

Or, conversely, just put qt_menu.nib in the 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/ 
+4
source

Source: https://habr.com/ru/post/1261876/


All Articles