簡體   English   中英

GDB:ModuleNotFoundError:沒有名為“_tkinter”的模塊

[英]GDB: ModuleNotFoundError: No module named '_tkinter'

So I'm trying to debug my C code ran in Python ctypes: gdb: break in shared library loaded by python . 但是,每當我運行 gdb 時,我都會收到以下錯誤: ModuleNotFoundError: No module named '_tkinter' 我知道關於這個錯誤有很多問題: matplotlib error - no module named tkinterImportError: No module named 'Tkinter' 我嘗試了以下方法:

sudo apt-get install python-tk

sudo apt-get install python3-tk

從 Ubuntu 命令行執行時它工作得非常好: brandon@DESKTOP-V5LTF5T:~$ python3 MainApp.py但從 gdb 執行時它不起作用: 在此處輸入圖像描述 為什么它可以在終端上工作,而不是 gdb?

您已經為 python3 安裝安裝了tkinter ,但是您正在從 GDB 運行python3-dbg 幸運的是,解決方案很簡單:為調試解釋器( python3-tk-dbg )安裝 tkinter:

➜  ~ 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
>>> 

我面臨同樣的錯誤。升級你的 Python 版本。我希望這對你有用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM