Skip to content

Importing 'pyqtgraph.opengl' raised: ModuleNotFoundError: No module named 'OpenGL' #7991

@zapta

Description

@zapta

I have a pyinstall project that worked well but now fails to build after I upgraded Python and pip packages to the latest. The program has no problems running the normal way using the .py files.

Any suggestion on how to fix it? More information below.

The root error seems to be this but I am not 100% sure. Full log at the bottom of this post.

1469 WARNING: Failed to collect submodules for 'pyqtgraph.opengl' because importing 'pyqtgraph.opengl' raised: ModuleNotFoundError: No module named 'OpenGL'

Pyinstaller command (and all source files): https://github.com/zapta/ble_stepper_motor_analyzer/blob/main/python/pyinstaller/build_on_windows.bat

Python version: Python 3.12.0
OS Name Microsoft Windows 10 Pro
Version 10.0.19045 Build 19045
Processor AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx, 2300 Mhz, 4 Core(s), 8 Logical Processor(s)

Pip freeze:

r$ pip freeze
altgraph==0.17.4
async-timeout==4.0.3
bleak==0.21.1
contourpy==1.1.1
cycler==0.12.1
fonttools==4.43.1
kiwisolver==1.4.5
matplotlib==3.8.0
multipledispatch==1.0.0
natsort==8.4.0
numpy==1.26.0
packaging==23.2
pandas==2.1.1
pandas-flavor==0.6.0
pefile==2023.2.7
Pillow==10.0.1
progress==1.6
pyinstaller==6.0.0
pyinstaller-hooks-contrib==2023.9
pyjanitor==0.26.0
pyparsing==3.1.1
PyQt6==6.5.2
PyQt6-Qt6==6.5.2
PyQt6-sip==13.5.2
pyqtgraph==0.13.3
pyserial==3.5
pyserial-asyncio==0.6
python-dateutil==2.8.2
pythoncrc==1.21
pytz==2023.3.post1
pywin32-ctypes==0.2.2
scipy==1.11.3
serial_packets==0.2.1
setuptools==68.2.2
six==1.16.0
stm32loader==0.5.1
tzdata==2023.3
winrt-runtime==2.0.0b1
winrt-Windows.Devices.Bluetooth==2.0.0b1
winrt-Windows.Devices.Bluetooth.Advertisement==2.0.0b1
winrt-Windows.Devices.Bluetooth.GenericAttributeProfile==2.0.0b1
winrt-Windows.Devices.Enumeration==2.0.0b1
winrt-Windows.Foundation==2.0.0b1
winrt-Windows.Foundation.Collections==2.0.0b1
winrt-Windows.Storage.Streams==2.0.0b1
xarray==2023.9.0

Log and errormessage

>pyinstaller ..\analyzer/analyzer.py   --paths ".."   --clean   --onefile   --distpath _dist    --workpath _build   --specpath _spec
927 INFO: PyInstaller: 6.0.0
928 INFO: Python: 3.12.0
1009 INFO: Platform: Windows-10-10.0.19045-SP0
1011 INFO: wrote _spec\analyzer.spec
1016 INFO: Removing temporary files and cleaning cache in C:\Users\user\AppData\Local\pyinstaller
1022 INFO: Extending PYTHONPATH with paths
['C:\\Users\\user\\projects\\ble_stepper_motor_analyzer\\repo',
 'C:\\Users\\user\\projects\\ble_stepper_motor_analyzer\\repo\\python']
2153 INFO: checking Analysis
2153 INFO: Building Analysis because Analysis-00.toc is non existent
2153 INFO: Initializing module dependency graph...
2159 INFO: Caching module graph hooks...
2214 INFO: Analyzing base_library.zip ...
6175 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
6484 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
10923 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
14504 INFO: Caching module dependency graph...
14825 INFO: Running Analysis Analysis-00.toc
14825 INFO: Looking for Python shared library...
14840 INFO: Using Python shared library: C:\Users\user\AppData\Local\Programs\Python\Python312\python312.dll
14840 INFO: Analyzing C:\Users\user\projects\ble_stepper_motor_analyzer\repo\python\analyzer\analyzer.py
15097 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
15423 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
17409 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
17458 INFO: Loading module hook 'hook-pyqtgraph.py' from 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
1469 WARNING: Failed to collect submodules for 'pyqtgraph.opengl' because importing 'pyqtgraph.opengl' raised: ModuleNotFoundError: No module named 'OpenGL'
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\__main__.py", line 205, in _console_script_run
    run()
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\__main__.py", line 189, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\__main__.py", line 61, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\build_main.py", line 1033, in main
    build(specfile, distpath, workpath, clean_build)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\build_main.py", line 973, in build
    exec(code, spec_namespace)
  File "_spec\analyzer.spec", line 4, in <module>
    a = Analysis(
        ^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\build_main.py", line 466, in __init__
    self.__postinit__()
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__
    self.assemble()
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\build_main.py", line 604, in assemble
    priority_scripts.append(self.graph.add_script(script))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\depend\analysis.py", line 268, in add_script
    self._top_script_node = super().add_script(pathname)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1260, in add_script
    self._process_imports(n)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2704, in _process_imports
    target_modules = self._safe_import_hook(*import_info, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\depend\analysis.py", line 432, in _safe_import_hook
    return super()._safe_import_hook(target_module_partname, source_module, target_attr_names, level, edge_attr)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2161, in _safe_import_hook
    target_modules = self.import_hook(
                     ^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1332, in import_hook
    target_package, target_module_partname = self._find_head_package(
                                             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1511, in _find_head_package
    target_package = self._safe_import_module(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\depend\analysis.py", line 479, in _safe_import_module
    return super()._safe_import_module(module_basename, module_name, parent_package)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1893, in _safe_import_module
    self._process_imports(n)
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2704, in _process_imports
    target_modules = self._safe_import_hook(*import_info, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\depend\analysis.py", line 368, in _safe_import_hook
    excluded_imports = self._find_all_excluded_imports(source_module.identifier)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\depend\analysis.py", line 356, in _find_all_excluded_imports
    excluded_imports.update(module_hook.excludedimports)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\depend\imphook.py", line 316, in __getattr__
    self._load_hook_module()
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\depend\imphook.py", line 383, in _load_hook_module
    self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\compat.py", line 626, in importlib_load_source
    return mod_loader.load_module()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 648, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1175, in load_module
  File "<frozen importlib._bootstrap_external>", line 999, in load_module
  File "<frozen importlib._bootstrap>", line 537, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 960, in _load
  File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-pyqtgraph.py", line 37, in <module>
    all_imports = collect_submodules("pyqtgraph", filter=lambda name: name != "pyqtgraph.examples")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 618, in collect_submodules
    modules, subpackages, on_error = isolated_python.call(_collect_submodules, name, on_error)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\isolated\_parent.py", line 307, in call
    raise SubprocessDiedError(
PyInstaller.isolated._parent.SubprocessDiedError: Child process died calling _collect_submodules() with args=('pyqtgraph.canvas', 'ignore') and kwargs={}. Its exit code was 3221225725.

Metadata

Metadata

Assignees

No one assigned

    Labels

    not-our-bugtriagePlease triage and relabel this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions