Python3.5安装tkinter

系统环境:CentOS 6.7 64bit

1) yum -y install tkinter tcl-devel tk-devel

安装完以后的库以及头文件为:

[root@localhost lib]# ll /usr/lib64/libtk*
lrwxrwxrwx. 1 root root      11 Dec 12 06:28 /usr/lib64/libtk.so -> libtk8.5.so

[root@localhost lib]# ll /usr/lib64/libtcl.so
lrwxrwxrwx. 1 root root 12 Dec 12 06:28 /usr/lib64/libtcl.so -> libtcl8.5.so

[root@localhost include]# ll /usr/include/tcl.h
-rw-r--r--. 1 root root 87115 Nov 11  2010 /usr/include/tcl.h
[root@localhost include]# ll /usr/include/tk.h
-rw-r--r--. 1 root root 57479 Nov 11  2010 /usr/include/tk.h

 

2) 修改Python-3.5.0/Modules/Setup.dist

# The _tkinter module.
#
# The command for _tkinter is long and site specific.  Please
# uncomment and/or edit those parts as indicated.  If you don't have a
# specific extension (e.g. Tix or BLT), leave the corresponding line
# commented out.  (Leave the trailing backslashes in!  If you
# experience strange errors, you may want to join all uncommented
# lines and remove the backslashes -- the backslash interpretation is
# done by the shell's "read" command and it may not be implemented on
# every system.

将下面几句的注释去掉:

# *** Always uncomment this (leave the leading underscore in!):
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
# *** Uncomment and edit to reflect where your Tcl/Tk libraries are:
-L/usr/lib64 \
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:
-I/usr/include \

# *** Uncomment and edit to reflect your Tcl/Tk versions:
-ltk8.5 -ltcl8.5 \

# *** Always uncomment this; X11 libraries to link with:
-lX11

3)重新编译Python3.5

/configure

make

make install

4) 验证

[root@localhost Python-3.5.0]# python
Python 3.5.0 (default, Dec 12 2018, 06:47:47)
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>>

 

如果是在windows或者图形化的linux下执行python -m tkinter,可以弹出tk窗口。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值