Nuitka: pyqtgraph importlib ModuleNotFoundError issue

or maybe it is just an importlib issue

Trying to compile minimalistic pyqtgraph(PyQt5) application (pyqtgraph_minimal.py):

from pyqtgraph import plot, exec

win = plot()
win.setWindowTitle('pyqtgraph example')

if __name__ == '__main__':
    exec()

with

python3 -m nuitka --plugin-enable=numpy --plugin-enable=pyqt5 --onefile pyqtgraph_minimal.py

in clean virtualenv, having latest packages available through pip, pip3 list output:

Package    Version
---------- --------
Nuitka     0.6.17.1
numpy      1.21.2
pip        21.2.4
PyQt5      5.15.4
PyQt5-Qt5  5.15.2
PyQt5-sip  12.9.0
pyqtgraph  0.12.2
setuptools 58.1.0
wheel      0.37.0

but getting (maybe import) error after application start:

Traceback (most recent call last):
  File "/tmp/.mount_pyqtgrYCHjBB/pyqtgraph_minimal.py", line 7, in <module>
    from pyqtgraph import plot, exec
  File "/tmp/.mount_pyqtgrYCHjBB/pyqtgraph/__init__.py", line 205, in <module pyqtgraph>
  File "/tmp/.mount_pyqtgrYCHjBB/pyqtgraph/graphicsItems/GraphicsLayout.py", line 5, in <module pyqtgraph.graphicsItems.GraphicsLayout>
  File "/tmp/.mount_pyqtgrYCHjBB/pyqtgraph/graphicsItems/ViewBox/__init__.py", line 1, in <module pyqtgraph.graphicsItems.ViewBox>
  File "/tmp/.mount_pyqtgrYCHjBB/pyqtgraph/graphicsItems/ViewBox/ViewBox.py", line 1742, in <module pyqtgraph.graphicsItems.ViewBox.ViewBox>
  File "/tmp/.mount_pyqtgrYCHjBB/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py", line 7, in <module pyqtgraph.graphicsItems.ViewBox.ViewBoxMenu>
  File "importlib.py", line 127, in import_module
ModuleNotFoundError: No module named 'pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5'

build log:

Nuitka-Options:INFO: Used command line options: --plugin-enable=numpy --plugin-enable=pyqt5 --onefile pyqtgraph_minimal.py
Nuitka:INFO: Starting Python compilation with Nuitka '0.6.17.1' on Python '3.8' commercial None.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'tkinter' added '_tkinter'.                                       
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'ctypes' added '_ctypes'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.core' added 'numpy.core._dtype_ctypes,numpy.core._multiarray_tests'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'pkg_resources.extern' added 'pkg_resources._vendor.packaging,pkg_resources._vendor.pyparsing,pkg_resources._vendor.appdirs'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'pkg_resources._vendor.packaging' added 'pkg_resources._vendor.packaging.version,pkg_resources._vendor.packaging.specifiers,pkg_resources._vendor.packaging.requirements'.                                 
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy' added 'numpy.compat,numpy.lib,numpy.linalg,numpy.fft,numpy.polynomial,numpy.random,numpy.random._bounded_integers,numpy.random._common,numpy.random._generator,numpy.random._mt19937,numpy.random._pcg64,numpy.random._philox,numpy.random._sfc64,numpy.random.bit_generator,numpy.random.mtrand,numpy.ctypeslib,numpy.ma,numpy.matrixlib'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.random.mtrand' added 'numpy,numpy.random.bit_generator,numpy.typing'.                                                                                                                               
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.random.bit_generator' added 'abc,threading,numpy,numpy.typing'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.random._sfc64' added 'numpy,numpy.random.bit_generator,numpy.typing'.                                                                                                                               
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.random._philox' added 'numpy,numpy.random.bit_generator,numpy.typing'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.random._pcg64' added 'numpy.random.bit_generator,numpy.typing'.                                                                                                                                     
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.random._mt19937' added 'numpy,numpy.random.bit_generator,numpy.typing'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.random._generator' added 'numpy,numpy.typing'.             
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'numpy.random' added 'numpy.random._bounded_integers,numpy.random._common,numpy.random._generator,numpy.random._mt19937,numpy.random._pcg64,numpy.random._philox,numpy.random._sfc64,numpy.random.bit_generator,numpy.random.mtrand'.                                                                                                               
Nuitka-Plugins:INFO: pyqt5: Injecting post-module load code for module 'PyQt5.QtCore':
Nuitka-Plugins:INFO: pyqt5:     Setting Qt library path to distribution folder. We need to avoid loading target                          
Nuitka-Plugins:INFO: pyqt5:     system Qt plug-ins, which may be from another Qt version.                                                
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'PyQt5.QtTest' added 'PyQt5.sip,PyQt5.QtWidgets,PyQt5.QtCore,datetime'.
Nuitka-Plugins:INFO: pyqt5: Implicit dependencies of module 'PyQt5.QtTest' added 'PyQt5.QtCore,PyQt5.QtGui,PyQt5.QtWidgets'.             
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'PyQt5.QtSvg' added 'PyQt5.sip,PyQt5.QtWidgets,PyQt5.QtGui,PyQt5.QtCore,datetime'.                                                                                                                         
Nuitka-Plugins:INFO: pyqt5: Implicit dependencies of module 'PyQt5.QtSvg' added 'PyQt5.QtCore,PyQt5.QtGui,PyQt5.QtWidgets'.
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'PyQt5.QtWidgets' added 'PyQt5.sip,PyQt5.QtGui,PyQt5.QtCore,datetime'.
Nuitka-Plugins:INFO: pyqt5: Implicit dependencies of module 'PyQt5.QtWidgets' added 'PyQt5.QtGui'.                                       
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'PyQt5.QtGui' added 'PyQt5.sip,PyQt5.QtCore,datetime,PyQt5.QtWidgets'.                                                                                                                                     
Nuitka-Plugins:INFO: pyqt5: Implicit dependencies of module 'PyQt5.QtGui' added 'PyQt5.QtCore'.                                          
Nuitka-Plugins:INFO: implicit-imports: Implicit dependencies of module 'PyQt5.QtCore' added 'PyQt5.sip,datetime,PyQt5.QtWidgets'.
Nuitka-Plugins:INFO: pyqt5: Implicit dependencies of module 'PyQt5.QtCore' added 'PyQt5.sip'.                                            
Nuitka:INFO: Completed Python level compilation and optimization.                                                                        
Nuitka:INFO: Generating source code for C backend compiler.                                                                              
Nuitka:INFO: Running data composer tool for optimal constant value handling.                                                             
Nuitka:INFO: Running C level backend compilation via Scons.                                                                              
Nuitka-Scons:INFO: Backend C compiler: gcc (gcc).
Nuitka-Scons:INFO: Compiled 266 C files using ccache.                                                                                    
Nuitka-Scons:INFO: Cached C files (using ccache) with result 'cache hit': 264                                                            
Nuitka-Scons:INFO: Cached C files (using ccache) with result 'cache miss': 2
Nuitka-Plugins:INFO: pyqt5: Copying Qt plug-ins 'iconengines,imageformats,mediaservice,platforms,platformthemes,printsupport,xcbglintegrations' to 'pyqtgraph_minimal.dist/PyQt5/qt-plugins'.
Nuitka-Postprocessing:INFO: Creating single file from dist folder, this may take a while.
Nuitka-Postprocessing:INFO: Completed onefile creation.
Nuitka:INFO: Keeping dist folder 'pyqtgraph_minimal.dist' for inspection, no need to use it.
Nuitka:INFO: Keeping build directory 'pyqtgraph_minimal.build'.
Nuitka:INFO: Successfully created 'pyqtgraph_minimal.bin'.

found (maybe) similar issue related to importlib: #1175

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 33 (18 by maintainers)

Most upvoted comments

Current Nuitka develop needs no import help anymore, so that is fantastic news.

Yes, that is what it is about. Nuitka now resolves the code that computes this at compile time and only includes them if they are necessary. And switching bindings is of course easy then too.