tit*_*dam 5 python macos terminal pyinstaller
我正在尝试使用PyInstaller创建一个独立的OSX应用程序,它运行我已经制作的GUI.当我在终端中输入以下内容时:
pyinstaller gui.py
Run Code Online (Sandbox Code Playgroud)
一切似乎都有效,直到我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
这看起来很奇怪,因为我的名字不是felipe!
我有一些问题:
1)如何在我的计算机上以名称felipe存在目录?(我用anaconda安装qt,我不知道这是否与它有关?)
2)直到我收到错误消息,PyInstaller正在查找正确的文件夹.为什么它开始寻找这个含糊不清的模糊(对我来说模糊)我不知道的目录?
3)我对目录很新手,我无法在计算机上的任何地方找到felipe先生.当我查看Users文件夹时,我只看到自己的用户和一个空的"Shared"文件夹.(我不知道共享文件夹的用途和原因.)
4)根据我在互联网上阅读的内容,我将qt_menu-nib复制到了应该变成独立脚本的文件夹.为了从这里成功创建独立,我该怎么办?
首先,您面临 PyInstaller 和 Anaconda 之间的一个已知问题:PyInstaller issues #2135。对话包含您问题的答案。
1) 该路径被硬编码在 Anaconda 提供的错误构建的 Qt 二进制文件中,请参阅mrady3 的评论。
2) PyInstaller 加载Qt4 特定的钩子,以查找qt_menu.nib运行目标应用程序所需的资源 ( )。挂钩代码尝试从 Qt 二进制文件本身获取资源目录的位置。Qt 二进制文件返回错误的/硬编码/路径,并且该过程失败后。
3)参见第1)点,它是维护者机器上的一个文件夹。Qt 假设其安装路径是在构建之前预先设置好的;Anaconda 存储库托管一个使用另一个安装路径编译的二进制文件。
4)可能有几种可能的方法:
尝试从源安装 PyInstaller 的开发人员版本,它对上述问题进行了一些修复。然后尝试再次构建应用程序:
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
Run Code Online (Sandbox Code Playgroud)
使用homebrew安装 Qt4 。本地编译会花费很长时间:
brew install cartr/qt4/qt
find /usr/local/Cellar/qt -name qt_menu.nib
Run Code Online (Sandbox Code Playgroud)
编辑 Qt4 挂钩/Users/username/anaconda/lib/python2.7/site-
packages/PyInstaller/hooks/hook-PyQt4.py并将调用替换qt_menu_nib_dir('PyQt4')为自制软件安装路径 ( '/usr/local/Cellar/qt/4.8.7_3/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib')。
或者,只需放入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/
Run Code Online (Sandbox Code Playgroud)