GDB: ModuleNotFoundError: No module named _tkinter [duplicate]
2024/11/19 11:29:05
So I'm trying to debug my C code ran in Python ctypes: gdb: break in shared library loaded by python.
However, whenever I run the gdb I get the following error: ModuleNotFoundError: No module named '_tkinter'. I know there's a lot of questions about this error: matplotlib error - no module named tkinter, and ImportError: No module named 'Tkinter'. I've tried the following:
sudo apt-get install python-tk
and
sudo apt-get install python3-tk
And it works perfectly fine when executing from Ubuntu command line: brandon@DESKTOP-V5LTF5T:~$ python3 MainApp.py
But it does not work when executing from gdb:
Why would it work from the terminal but not gdb?
Answer
You have installed tkinter for your python3 installation, but you are running python3-dbg from GDB. Luckily, the solution is simple: install tkinter for the debugging interpreter (python3-tk-dbg):
➜ ~ python3-dbg
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/usr/lib/python3.6/tkinter/__init__.py", line 36, in <module>import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
>>> ➜ ~ sudo apt install python3-tk-dbg
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:python3-tk-dbg
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/509 kB of archives.
After this operation, 1,441 kB of additional disk space will be used.
Selecting previously unselected package python3-tk-dbg:amd64.
(Reading database ... 205251 files and directories currently installed.)
Preparing to unpack .../python3-tk-dbg_3.6.9-1~18.04_amd64.deb ...
Unpacking python3-tk-dbg:amd64 (3.6.9-1~18.04) ...
Setting up python3-tk-dbg:amd64 (3.6.9-1~18.04) ...➜ ~ python3-dbg
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>>
This question already has answers here:Float to Int type conversion in Python for large integers/numbers(2 answers)Closed last year.Why is the result of below code 0 in python3?
a = "4.1512940685…
I would like to use sns.seaborn to display the np.sum and the np.mean on 2 different axes (with ax2 = ax1.twinx() I assume). The probem I have is that the graphs are overlapped and not readable.Am I ap…
This question already has an answer here:TensorFlow Importing error ( Using Anaconda)(1 answer)Closed 2 years ago.I need tensorflow to run a guided project I did on Coursera, but I am not able to insta…
I want to extract the information between CVE and |, but only the first time that CVE appear in the txt. I have now the follow code:import re
f = open (/Users/anna/PycharmProjects/extractData/DiarioOfi…
How can I reset a loop that iterates over a set? A common answer for iterating over a list is to reset the index you are using to access the list, however sets do not support indices. The point is to …
I have a cron job that runs at 12, 12:30,1, 1:30. So every half hour intervals on the clock. I want to run a thread in my python code whenever the cron job runs.I have seen examples where to run a tim…
I am making a simple countdown timer in minutes. I cant seem to display the countdown in text label. Can someone help me?import tkinter as tk
import timedef countdown(t):while t:mins, secs = divmod(t,…
In need of help from learned people on this forum. I just want to embed one pdf file to another pdf file. So that when I go to the attachment section of the second file I can get to see and open the fi…
Here is my code - sentence = input("Enter a sentence without punctuation")
sentence = sentence.lower()
words = sentence.split()
pos = [words.index(s)+1 for s in words]
hi = print("This s…
Assuming you have a python file like so#python
#comment
x = raw_input()
exec(x)How could you get the source of the entire file, including the comments with exec?