question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pyqtgraph importlib ModuleNotFoundError issue

See original GitHub 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:33 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
kayhayencommented, Nov 27, 2021

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

1reaction
kayhayencommented, Nov 28, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: ModuleNotFoundError: No module named 'pyqtgraph'?
I am guessing that your module gets installed to another Python version than what PYTHONPATH points to. Try pip3 list -v | grep...
Read more >
How to Check 'pyqt' Package Version in Python? - Finxter
In this article, I'll show you: How to check the version of the Python module (package, library) pyqt ? And how to check...
Read more >
PyInstaller Documentation - Read the Docs
PyInstaller runs on macOS 10.15 (Catalina) or newer. It can build graphical windowed apps (apps that do not use a terminal window).
Read more >
Errors while dynamic imports using importlib in python3
I have been trying to use importlib with python3 (3.6). ... line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'hello'. Problem.
Read more >
Understanding PyInstaller Hooks
warn once: The first error issues a warning but all subsequent errors are ignored ... is designed to mimic (albeit loosely) the importlib.metadata...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found