Skip to content

Python und GUI

Verschoben Python3
  • Dank des netten Tipps meines Systemadministrator mal folgendes ausprobiert.

    Maschine

    Ubuntu20.04 in Virtual Box

    Software Installation

    python3 ist drauf. Also folgendes

    rank@frank-VirtualBox:~/python$ python3 -m pip install pysimplegui
    /usr/bin/python3: No module named pip
    

    Ok, ist einfach

    frank@frank-VirtualBox:~/python$ sudo apt install python3-pip
    

    Danach geht es

    frank@frank-VirtualBox:~/python$ python3 -m pip install pysimplegui
    Collecting pysimplegui
      Downloading PySimpleGUI-4.29.0-py3-none-any.whl (357 kB)
         |████████████████████████████████| 357 kB 2.0 MB/s 
    Installing collected packages: pysimplegui
    Successfully installed pysimplegui-4.29.0
    

    Beispiel hello_world.py

    # hello_world.py
    
    import PySimpleGUI as sg
    
    sg.Window(title="Hello World", layout=[[]], margins=(100, 50)).read()
    

    Bei der Ausführung kommt folgender Fehler

    frank@frank-VirtualBox:~/python$ python3 hello_world.py 
    Traceback (most recent call last):
      File "hello_world.py", line 3, in <module>
        import PySimpleGUI as sg
      File "/home/frank/.local/lib/python3.8/site-packages/PySimpleGUI/__init__.py", line 2, in <module>
        from .PySimpleGUI import *
      File "/home/frank/.local/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 101, in <module>
        import tkinter as tk
    ModuleNotFoundError: No module named 'tkinter'
    

    Ok, fehlt noch was.

    frank@frank-VirtualBox:~/python$ sudo apt install python3-tk
    

    Danach funktioniert es.

    91b54d59-24ce-44d6-965c-749ae041c41c-grafik.png