[英]Error using PyInstaller
I'm trying to use PyInstaller to create a standalone OSX app that runs a GUI I've made. 我正在尝试使用PyInstaller创建一个独立的OSX应用程序,它运行我已经制作的GUI。 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! 这看起来很奇怪,因为我的名字不是felipe!
I have a couple of questions: 我有一些问题:
1) How is it possible that there is a directory under the name felipe on my computer? 1)如何在我的计算机上以名称felipe存在目录? (I used anaconda to install qt, I don't know whether that has something to do with it?)
(我用anaconda安装qt,我不知道这是否与它有关?)
2) Up until I get the error message, PyInstaller is looking in the correct folder. 2)直到我收到错误消息,PyInstaller正在查找正确的文件夹。 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. 3)我对目录很新手,我无法在计算机上的任何地方找到felipe先生。 When I look in the Users folder I just see my own user and an empty "Shared" folder.
当我查看Users文件夹时,我只看到自己的用户和一个空的“Shared”文件夹。 (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. 4)根据我在互联网上阅读的内容,我将qt_menu-nib复制到了应该变成独立脚本的文件夹中。 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 . 首先,你面对PyInstaller和Anaconda之间的一个已知问题: PyInstaller问题#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 . 1)路径是由Anaconda提供的错误构建的Qt二进制文件中的硬编码,请参阅mrady3的评论 。
2) PyInstaller loads Qt4-specific hook in order to find resources ( qt_menu.nib
) that are necessary for running target app. 2)PyInstaller加载特定于Qt4的钩子 ,以便找到运行目标应用程序所必需的资源(
qt_menu.nib
)。 The hook code tries to obtain location of resource directory from the Qt binary itself. 钩子代码试图从Qt二进制文件本身获取资源目录的位置。 Qt binary returns wrong /hardcoded/ path, and after that process fails.
Qt二进制文件返回错误/硬编码/路径,并在该过程失败后。
3) See point 1), it was a folder on maintainer's machine. 3)参见第1点),它是维护者机器上的一个文件夹。 Qt assumes that its installation path is pre-set before building;
Qt假设它的安装路径是在建造之前预先设定的; Anaconda repository hosts a binary that was compiled with another installation path in mind.
Anaconda存储库托管了一个二进制文件,该二进制文件在编译时考虑了另
4) There could be several possible approaches: 4)可能有几种可能的方法:
Try installing developer version of PyInstaller from sources, it has some fixes for the above-mentioned issue . 尝试从源代码安装PyInstaller的开发者版本,它对上述问题有一些修复 。 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 . 使用自制软件安装Qt4。 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'
). 在
/Users/username/anaconda/lib/python2.7/site- packages/PyInstaller/hooks/hook-PyQt4.py
编辑Qt4钩子,并用来自homebrew installation( '/usr/local/Cellar/qt/4.8.7_3/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib'
qt_menu_nib_dir('PyQt4')
的路径替换对qt_menu_nib_dir('PyQt4')
调用'/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: 或者,只需将
qt_menu.nib
放入预期位置:
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/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.