vscode无法加载tkinter如何解决


本文摘自PHP中文网,作者尚,侵删。

学Python配置完了VScode,在安装easygui后遇到了一些问题。

代码如下:

1

2

import easygui

easygui.msgbox("Hello world.")

Ctrl+Shift+B,运行报错,报错如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

Traceback (most recent call last):

  File "/usr/lib/python3.5/tkinter/__init__.py", line 36, in <module>

    import _tkinter

ImportError: No module named '_tkinter'

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/home/hongludianxue/.local/lib/python3.5/site-packages/easygui/boxes/utils.py", line 29, in <module>

    import tkinter as tk  # python3

  File "/usr/lib/python3.5/tkinter/__init__.py", line 38, in <module>

    raise ImportError(str(msg) + ', please install the python3-tk package')

ImportError: No module named '_tkinter', please install the python3-tk package

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/home/hongludianxue/.local/lib/python3.5/site-packages/easygui/boxes/utils.py", line 36, in <module>

    import Tkinter as tk  # python2

ImportError: No module named 'Tkinter'

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/home/hongludianxue/.local/lib/python3.5/site-packages/easygui/boxes/button_box.py", line 15, in <module>

    from . import utils as ut

  File "/home/hongludianxue/.local/lib/python3.5/site-packages/easygui/boxes/utils.py", line 43, in <module>

    raise ImportError("Unable to find tkinter package.")

ImportError: Unable to find tkinter package.

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/home/hongludianxue/Documents/Python file/0x00.py", line 1, in <module>

    import easygui

  File "/home/hongludianxue/.local/lib/python3.5/site-packages/easygui/__init__.py", line 34, in <module>

    from .boxes.button_box import buttonbox

  File "/home/hongludianxue/.local/lib/python3.5/site-packages/easygui/boxes/button_box.py", line 18, in <module>

    import global_state

ImportError: No module named 'global_state'

看到ImportError: No module named '_tkinter'才知道,原来是没有tkinter这个模块。

在终端里面安装上tkinter:

1

sudo apt-get install python3-tk

完成之后在运行之前的Python代码,发现已经成功运行啦。

推荐学习:vscode教程

以上就是vscode无法加载tkinter如何解决的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

vsCode怎么导入jar包

vsCode能编辑dll库文件么

如何使用vsCode打开浏览器查看html文件

提高开发效率的 vsCode 插件(极力推荐!)

vsCode怎么支持vue

vsCode怎么修改标签颜色

vsCode中无法切换输入法

vsCode中怎么实现自动缩进

vsCode如何搭建vue项目

vsCode关闭错误提示

更多相关阅读请进入《vsCode》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...