Nuitka: import PySimpleGUIQt as sg: FAILURE: '--standalone', SUCCESS: '--follow-imports'.

Created on 1 Oct 2019  路  7Comments  路  Source: Nuitka/Nuitka

Hello Kay,

I think this might be related to issue #513.


This works:
python -m nuitka --follow-imports test.py


This does not work (neither of them):
python -m nuitka --standalone test.py

Nuitka:WARNING:Use '--plugin-enable=qt-plugins' for: Inclusion of Qt plugins.
Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\nuitka\__main__.py", line 184, in <module>
    main()
  File "C:\Python35\lib\site-packages\nuitka\__main__.py", line 177, in main
    MainControl.main()
  File "C:\Python35\lib\site-packages\nuitka\MainControl.py", line 766, in main
    main_module = createNodeTree(filename=filename)
  File "C:\Python35\lib\site-packages\nuitka\MainControl.py", line 141, in createNodeTree
    Optimization.optimize(main_module.getOutputFilename())
  File "C:\Python35\lib\site-packages\nuitka\optimizations\Optimization.py", line 616, in optimize
    makeOptimizationPass(initial_pass=True)
  File "C:\Python35\lib\site-packages\nuitka\optimizations\Optimization.py", line 530, in makeOptimizationPass
    changed = optimizeModule(current_module)
  File "C:\Python35\lib\site-packages\nuitka\optimizations\Optimization.py", line 165, in optimizeModule
    optimizeShlibModule(module)
  File "C:\Python35\lib\site-packages\nuitka\optimizations\Optimization.py", line 160, in optimizeShlibModule
    Plugins.considerImplicitImports(module=module, signal_change=signalChange)
  File "C:\Python35\lib\site-packages\nuitka\plugins\Plugins.py", line 128, in considerImplicitImports
    plugin.considerImplicitImports(module, signal_change)
  File "C:\Python35\lib\site-packages\nuitka\plugins\PluginBase.py", line 173, in considerImplicitImports
    for full_name, required in self.getImplicitImports(module):
  File "C:\Python35\lib\site-packages\nuitka\plugins\standard\ImplicitImports.py", line 770, in getImplicitImports
    for used_module in module.getUsedModules():
  File "C:\Python35\lib\site-packages\nuitka\nodes\ModuleNodes.py", line 899, in getUsedModules
    self._readPyPIFile()
  File "C:\Python35\lib\site-packages\nuitka\nodes\ModuleNodes.py", line 878, in _readPyPIFile
    assert imported.endswith(")")
AssertionError

python -m nuitka --standalone --plugin-enable=qt-plugins test.py

Nuitka:INFO:Injecting plug-in based post load code for module 'PyQt5.QtCore':
Nuitka:INFO:    Setting Qt library path to distribution folder. Need to avoid loading target
Nuitka:INFO:    system Qt plug-ins, which may be from another Qt version.
Nuitka:INFO:Injecting plug-in based pre load code for module 'PyQt5':
Nuitka:INFO:    Adding dist folder to 'PATH' environment variable.
Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\nuitka\__main__.py", line 184, in <module>
    main()
  File "C:\Python35\lib\site-packages\nuitka\__main__.py", line 177, in main
    MainControl.main()
  File "C:\Python35\lib\site-packages\nuitka\MainControl.py", line 766, in main
    main_module = createNodeTree(filename=filename)
  File "C:\Python35\lib\site-packages\nuitka\MainControl.py", line 141, in createNodeTree
    Optimization.optimize(main_module.getOutputFilename())
  File "C:\Python35\lib\site-packages\nuitka\optimizations\Optimization.py", line 616, in optimize
    makeOptimizationPass(initial_pass=True)
  File "C:\Python35\lib\site-packages\nuitka\optimizations\Optimization.py", line 530, in makeOptimizationPass
    changed = optimizeModule(current_module)
  File "C:\Python35\lib\site-packages\nuitka\optimizations\Optimization.py", line 165, in optimizeModule
    optimizeShlibModule(module)
  File "C:\Python35\lib\site-packages\nuitka\optimizations\Optimization.py", line 160, in optimizeShlibModule
    Plugins.considerImplicitImports(module=module, signal_change=signalChange)
  File "C:\Python35\lib\site-packages\nuitka\plugins\Plugins.py", line 128, in considerImplicitImports
    plugin.considerImplicitImports(module, signal_change)
  File "C:\Python35\lib\site-packages\nuitka\plugins\PluginBase.py", line 173, in considerImplicitImports
    for full_name, required in self.getImplicitImports(module):
  File "C:\Python35\lib\site-packages\nuitka\plugins\standard\ImplicitImports.py", line 770, in getImplicitImports
    for used_module in module.getUsedModules():
  File "C:\Python35\lib\site-packages\nuitka\nodes\ModuleNodes.py", line 899, in getUsedModules
    self._readPyPIFile()
  File "C:\Python35\lib\site-packages\nuitka\nodes\ModuleNodes.py", line 878, in _readPyPIFile
    assert imported.endswith(")")
AssertionError

----

test.py:

import PySimpleGUIQt as sg

This is on Windows 10 (64 bit):

python -m nuitka --version

0.6.6rc5
Python: 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)]
Executable: C:\Python35\python.exe
OS: Windows
Arch: x86_64

Here is how I installed the Python libraries:

pip install PySimpleGUIQt
pip install PySide2
pip install PyQt5
pip uninstall nuitka
pip install -U "https://nuitka.net/doc/factory.html"

Note: the pip install -U "https://nuitka.net/doc/factory.html" was done on 09/18/2019.

Thanks,
George Hynes
10/01/2019 4:53pm ET

Most helpful comment

Sorry that your path seems so much like "from Dracula to the bloodletting" (as we say in German) :-)

What you need to do is specifying the right plugins when doing standalone compiles.
One more time I am recommending hinted compilation, which would take over this for you.

But anyway, when using tkinter on Windows you need to do python -m nuitka --standalone --enable-plugin=tk-inter yourscript.py.
This plugin will copy the required TK/TCL data directories to your dist folder in the right way.

Easily of course, you have more than just Tkinter in your script, say numpy and/or scipy and/or matplotlib, etc.. So the command line quickly becomes very long and error-prone ... and the resulting dist folder very large, compile times very long ...

Hinted compilation will help here in many cases. Not always, I must admit.

All 7 comments

As far as I recall, PySide is not supported by Nuitka.

Hi Jorj,

ok, I saw #170 (would be great if a reasonable solution was found, but I understand), so I changed PySimpleGUIQt (which uses either Qt5 or PySide2), to PySimpleGUI (which uses Tkinter).


This is on Windows 10 (64 bit):

python -m nuitka --version

0.6.6rc5
Python: 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)]
Executable: C:\Python35\python.exe
OS: Windows
Arch: x86_64

pip install PySimpleGUI


test_GUI.py:

import PySimpleGUI as sg

layout = [[sg.Button('Button', key='Button')]]

window = sg.Window("Acme, Inc.", layout)

keepLooping = True
while (keepLooping == True): 
    event, values = window.Read()
    if event in ('Button'):
        keepLooping = False

window.Close()

This works ( I can execute the created test_GUI.exe without issues):
python -m nuitka --follow-imports test_GUI.py

This also compiles, but does not work when I try to execute my EXE:
python -m nuitka --standalone test_GUI.py

Error when I try to run my EXE:

Traceback (most recent call last):
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\test_GUI.py", line 9, in <module>
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\PySimpleGUI\PySimpleGUI.py", line 5422, in Read
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\PySimpleGUI\PySimpleGUI.py", line 5291, in _Show
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\PySimpleGUI\PySimpleGUI.py", line 8836, in StartupTK
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\tkinter\__init__.py", line 1876, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:

C:/SOURCE_CONTROL/Design_Engineering/HexManager/PYTHON_STUFF/NUITKA/001_TEST_NO_PYSIDE2/lib/tcl8.6
C:/SOURCE_CONTROL/Design_Engineering/HexManager/PYTHON_STUFF/NUITKA/001_TEST_NO_PYSIDE2/lib/tcl8.6
C:/SOURCE_CONTROL/Design_Engineering/HexManager/PYTHON_STUFF/NUITKA/lib/tcl8.6
C:/SOURCE_CONTROL/Design_Engineering/HexManager/PYTHON_STUFF/NUITKA/001_TEST_NO_PYSIDE2/library
C:/SOURCE_CONTROL/Design_Engineering/HexManager/PYTHON_STUFF/NUITKA/library
C:/SOURCE_CONTROL/Design_Engineering/HexManager/PYTHON_STUFF/NUITKA/tcl8.6.4/library
C:/SOURCE_CONTROL/Design_Engineering/HexManager/PYTHON_STUFF/tcl8.6.4/library

This probably means that Tcl wasn't installed properly.

Ok, so I copied the file (and created TO dir.):

COPY FROM:
C:\Python35\tcl\tcl8.6\init.tcl

TO:
C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\lib\tcl8.6\init.tcl

-but now I get this error:

Traceback (most recent call last):
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\test_GUI.py", line 9, in <module>
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\PySimpleGUI\PySimpleGUI.py", line 5422, in Read
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\PySimpleGUI\PySimpleGUI.py", line 5291, in _Show
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\PySimpleGUI\PySimpleGUI.py", line 8836, in StartupTK
  File "C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\test_GUI.dist\tkinter\__init__.py", line 1876, in __init__
_tkinter.TclError: invalid command name "tcl_findLibrary"

Ok, so finally I did the following (and this seemed to work, but it's a hack for sure):

COPY ALL FROM:

C:\Python35\tcl\tcl8.6\*
C:\Python35\tcl\tk8.6\*

TO:

C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\lib\tcl8.6\*
C:\SOURCE_CONTROL\Design_Engineering\HexManager\PYTHON_STUFF\NUITKA\001_TEST_NO_PYSIDE2\lib\tk8.6\*

-after doing the above, I could execute successfully:
C:SOURCE_CONTROLDesign_EngineeringHexManagerPYTHON_STUFFNUITKA001_TEST_NO_PYSIDE2test_GUI.disttest_GUI.exe

Do you have a better solution that is more "Nuitka-like"?

----

Question 1: I tried experimenting w/the Nuitka command line arguments, but I can't seem to figure out if there is a way to "tell it" to include some arbitrary files (like text files, or dll files, etc.) -or do I assume I should write a script that after Nuitka is done, that copies over the required files?

Question2 (not really related, but am curious): I understand I can create an EXE, but can I create my own *.pyd file, instead of an *.exe?

Thanks,
George Hynes
10/03/2019 4:25pm ET

Sorry that your path seems so much like "from Dracula to the bloodletting" (as we say in German) :-)

What you need to do is specifying the right plugins when doing standalone compiles.
One more time I am recommending hinted compilation, which would take over this for you.

But anyway, when using tkinter on Windows you need to do python -m nuitka --standalone --enable-plugin=tk-inter yourscript.py.
This plugin will copy the required TK/TCL data directories to your dist folder in the right way.

Easily of course, you have more than just Tkinter in your script, say numpy and/or scipy and/or matplotlib, etc.. So the command line quickly becomes very long and error-prone ... and the resulting dist folder very large, compile times very long ...

Hinted compilation will help here in many cases. Not always, I must admit.

Hi Jorj,

Thanks! I took your advice (haven't tried the hinted compilation, as of yet -but I will explore this), and it's working.

Thanks,
George Hynes
10/09/2019 2:08pm ET

@JorjMcKie
Your tk-inter import solution made my "pysimplegui" work!! Thankss! <3
How do I see the name of the plugin? For example, how would I know that "tkinter" equals "tk-inter"? I'm sorry for the silly question and the English

Try this command: python -m nuitka --plugin-list.

@JorjMcKie Perfect! Thank you!

Was this page helpful?
0 / 5 - 0 ratings