I am trying to run a programm using wsl. My python programm uses tkinter as a gui libary. When running the script I get this error:
Traceback (most recent call last):
File "/mnt/c/coding/11_python_playground/tim_rechner_bug/main.py", line 1, in <module>
import PySimpleGUI as sg
File "/home/jan/.local/lib/python3.10/site-packages/PySimpleGUI/__init__.py", line 2, in <module>
from .PySimpleGUI import *
File "/home/jan/.local/lib/python3.10/site-packages/PySimpleGUI/PySimpleGUI.py", line 140, in <module>
import tkinter as tk
File "/usr/local/lib/python3.10/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
My OS is wsl debian.
I installed python 3.10 from source following this tutorial https://computingforgeeks.com/how-to-install-python-on-ubuntu-linux-system/ .
I found different aproaches to fix this but none of them worked for me. Here are some solutions that I tried that did not fix the issue.
sudo apt install python3-tk
sudo apt install tk-dev
sudo apt install tk
pip3.10 install tk
python -m pip install tk-tools
The problem was fixed with the helpfull comment of @mousetail.
The fix was to use this instead of the configure line in the tutorial:
./configure --enable-optimizations --with-tcltk-includes='-I/opt/ActiveTcl-8.6/include' --with-tcltk-libs='-L/opt/ActiveTcl-8.6/lib/libtcl8.6.so /opt/ActiveTcl-8.6/lib/libtk8.6.so'
Thanks for all your efforts to help!