Nuitka: [OpenGL][pyqtgraph]Code with pyqtgraph.opengl Runtime Error After Compile
Similar with issue #2394 (Not the issue in title, but the one posted at bottom after labelled closed).
I used pyqtgraph.opengl to draw some 3D graphics and could successfully compiled the Python code, but got runtime errors.
python -m nuitka --version 1.9rc5 (also tried 1.8.4) Commercial: None Python: 3.9.15 (main, Nov 24 2022, 14:39:17) [MSC v.1916 64 bit (AMD64)] Flavor: Anaconda Python Executable: C:\ProgramData\Miniconda3\envs\isp64\python.exe OS: Windows Arch: x86_64 WindowsRelease: 10 Version C compiler: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe (cl 14.2).
Nuitka Install & Version
1.9rc5: python -m pip install -U --force-reinstall “https://github.com/Nuitka/Nuitka/archive/factory.zip”
Code Example
My project contains many irrelevant files thus no need to paste them here, it’s very easy to reproduce this issue, just use below code is enough:
import numpy as np
import pyqtgraph.opengl as gl
class HSVViewer(gl.GLViewWidget):
def __init__(self, parent=None):
gl.GLViewWidget.__init__(self, parent)
ax = gl.GLAxisItem()
ax.setSize(1.1, 1.1, 1.1)
self.addItem(ax)
Compile cmd
python -m nuitka --standalone --plugin-enable=pyqt6 --output-dir=out test.py
Error log
Unable to import OpenGL.platform.win32.Win32Platform: cannot import name ‘util’ from ‘ctypes’ (D:\Src\test\out\MIVISI~1.DIS\ctypes_init_.py) Traceback (most recent call last): File “D:\Src\test\out\MIVISI~1.DIS\GuiLayer\lut3d\gamut_mapping_tab.py”, line 8, in <module GuiLayer.lut3d.gamut_mapping_tab> File “<frozen importlib._bootstrap>”, line 1007, in _find_and_load File “<frozen importlib._bootstrap>”, line 986, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 680, in load_unlocked File "D:\Src\test\out\MIVISI~1.DIS\pyqtgraph_init.py", line 281, in <module pyqtgraph> File “<frozen importlib._bootstrap>”, line 1007, in _find_and_load File “<frozen importlib._bootstrap>”, line 986, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 680, in load_unlocked File “D:\Src\test\out\MIVISI~1.DIS\pyqtgraph\widgets\RawImageWidget.py”, line 13, in <module pyqtgraph.widgets.RawImageWidget> File "D:\Src\test\out\MiVision.dist\OpenGL\GL_init.py", line 3, in <module> from OpenGL import error as _error File “D:\Src\test\out\MiVision.dist\OpenGL\error.py”, line 12, in <module> from OpenGL import platform, configflags File "D:\Src\test\out\MiVision.dist\OpenGL\platform_init.py", line 56, in <module> load() File "D:\Src\test\out\MiVision.dist\OpenGL\platform_init.py", line 50, in _load plugin = plugin_class() TypeError: ‘NoneType’ object is not callable
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 1
- Comments: 16 (10 by maintainers)
Oh my, good old habit of mine, documenting my bugs with TODOs ahead of time.
The attribute lookup of what are “hard” modules is not going to resolved to the import, as it should be, but remains as a kind of attribute lookup only. Hard modules are used for highly optimized modules in Nuitka, mostly from stdlib, but recently also for some things that are lazy loading. I need to check what it entails to implement this TODO item.
Yes it’s not from my code because they were copied from pieces of notes just tried to make an example, as I didn’t have the environment when writing this ticket. I’ll update the example code and corresponding logs, thank you for the reply.