我使用以下命令安装了最新版本的PyInstaller:pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
我尝试使用以下命令捆绑最简单的代码:pyinstaller --onefile --noupx main.py
main.py
from OpenGL import GL
print("Hello, OpenGL")
我得到了一个错误:ImportError: cannot import name 'opengl_arrays_modules' from 'PyInstaller.utils.hooks'
全日志:
PS E:\_Projects\Python\SDL2\pyopengl_demo> pyinstaller --onefile main.py
124 INFO: PyInstaller: 4.0.dev0
124 INFO: Python: 3.7.8
138 INFO: Platform: Windows-10-10.0.18362-SP0
140 INFO: wrote E:\_Projects\Python\SDL2\pyopengl_demo\main.spec
283 INFO: UPX is available.
287 INFO: Extending PYTHONPATH with paths
['E:\\_Projects\\Python\\SDL2\\pyopengl_demo',
'E:\\_Projects\\Python\\SDL2\\pyopengl_demo']
338 INFO: checking Analysis
339 INFO: Building Analysis because Analysis-00.toc is non existent
340 INFO: Initializing module dependency graph...
351 INFO: Caching module graph hooks...
401 INFO: Analyzing base_library.zip ...
5023 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
5039 INFO: distutils: retargeting to non-venv dir 'c:\\program files (x86)\\python37-32\\lib'
7945 INFO: Caching module dependency graph...
8243 INFO: running Analysis Analysis-00.toc
8248 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\program files (x86)\python37-32\python.exe
8445 INFO: Analyzing E:\_Projects\Python\SDL2\pyopengl_demo\main.py
16293 INFO: Processing pre-find module path hook site from 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
16308 INFO: site: retargeting to fake-dir 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\fake-modules'
18941 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-setuptools.extern.six.moves.py'.
24985 INFO: Processing module hooks...
24988 INFO: Loading module hook 'hook-OpenGL.py' from 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
Traceback (most recent call last):
File "c:\program files (x86)\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files (x86)\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 716, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 663, in build
exec(code, spec_namespace)
File "E:\_Projects\Python\SDL2\pyopengl_demo\main.spec", line 17, in <module>
noarchive=False)
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
self.__postinit__()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 418, in assemble
self.graph.process_post_graph_hooks()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\depend\analysis.py", line 365, in process_post_graph_hooks
module_hook.post_graph()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\depend\imphook.py", line 440, in post_graph
self._load_hook_module()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\depend\imphook.py", line 407, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\compat.py", line 588, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 907, in load_module
File "<frozen importlib._bootstrap_external>", line 732, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-OpenGL.py", line 24, in <module>
from PyInstaller.utils.hooks import opengl_arrays_modules
ImportError: cannot import name 'opengl_arrays_modules' from 'PyInstaller.utils.hooks' (C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\utils\hooks\__init__.py)
发布于 2020-07-23 03:07:09
Pyinstaller开发人员最近对钩子进行了更改。OpenGL的那个已经转移到https://github.com/pyinstaller/pyinstaller-hooks-contrib了。我相信你还有以前安装的pyinstaller的旧钩子。这个程序将无法工作,因为它们也对代码进行了更改。您应该删除OpeenGL钩子(C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-OpenGL.py
)或删除pyinstaller并重新安装它。然后获取github中的contrib并使用--additional-hooks-dir
指向它
发布于 2020-08-26 05:01:34
使用python 3.8.5:
我试着升级钩子:
pip install -U pyinstaller-hooks-contrib
要升级钩子,它用
Requirement already up-to-date: pyinstaller-hooks-contrib in c:\python38\lib\site-packages (2020.7)
我删除了pip版本:
pip uninstall pyinstaller-hooks-contrib
因此,我不得不使用存储库文件进行更新:
git clone https://github.com/pyinstaller/pyinstaller-hooks-contrib.git
cd pyinstaller-hooks-contrib
python setup.py install
我现在已经设置了2020.8版本,并解决了初始问题。
发布于 2020-08-16 10:32:43
它不适用于wxPython。这都是我干的。我看到了
它与来自PySDL2和PySide2
的OpenGL合作
https://stackoverflow.com/questions/63052345
复制相似问题