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
    评论
要在Python中安装tkinter模块,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了Python解释器。如果你使用的是Python 2.7版本,那么tkinter模块通常已经预装在Python中。如果你使用的是Python 3版本,你可能需要手动安装tkinter模块。 2. 安装tkinter的方法因操作系统而异。对于Ubuntu 14.04系统,你可以使用apt-get命令来安装tkinter。在终端中运行以下命令: ``` sudo apt-get install python-tk ``` 对于其他操作系统,请参考相应的安装指南或搜索适用于你的操作系统的安装方法。 3. 如果你希望在Python 3.6.3中安装tkinter,可以使用apt-get命令安装Python 3.6版本。在终端中运行以下命令: ``` sudo apt-get install python3.6 ``` 4. 如果你想使用Python 3.5,并安装tkinter模块,请按照以下步骤进行操作: a. 使用apt-get命令安装Python 3.5版本: ``` sudo apt-get install python3.5 ``` b. 然后,使用以下命令安装tkinter模块: ``` sudo apt-get install python3.5-tk ``` 请注意,安装方法可能因你使用的操作系统和Python版本而有所不同。你可以参考中提供的参考文献,根据你的具体情况选择合适的安装方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [给python安装tkinter模块(及各种问题的解决:如 ModuleNotFoundError: No module named ‘_tkinter’)](https://blog.csdn.net/weixin_39278265/article/details/106651951)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值