国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python升級提示Tkinter模塊找不到的解決方法

2020-02-23 05:40:05
字體:
供稿:網(wǎng)友

一、安裝tkinter
在Linux中python默認是不安裝Tkinter模塊,
代碼如下:
[root@li250-193 ~]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Tkinter
>>>
我們安裝Tkinter模塊
代碼如下:
[root@li250-193 ~]# yum -y install tkinter
...
[root@li250-193 ~]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>
二、升級Python
Linux的Python版本默認都不叫低
查看Python版本
代碼如下:
[root@li250-193 ~]# python -V
Python 2.6.6

DOWN新版本
代碼如下:
[root@li250-193 ~]# wget http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz

解壓安裝
代碼如下:
[root@li250-193 ~]# tar -xf Python-2.7.4.tgz
[root@li250-193 ~]# cd Python-2.7.4
[root@li250-193 Python-2.7.4]# ./configure
...
[root@li250-193 Python-2.7.4]# make
...
[root@li250-193 Python-2.7.4]# make install
...

看看新版本Python是否可以使用Tkinter?
代碼如下:
[root@li250-193 Python-2.7.4]# ./python
Python 2.7.4 (default, Apr 12 2013, 08:03:09)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter      
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/Python-2.7.4/Lib/lib-tk/Tkinter.py", line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
>>>

提示找不到tkinter模塊?看看舊版的是不是正常
代碼如下:
[root@li250-193 Python-2.7.4]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>

舊版的沒問題,難道需要yum install tkinter一次?
代碼如下:
[root@li250-193 Python-2.7.4]# yum install tkinter
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirror.team-cymru.org
 * extras: mirror.team-cymru.org
 * updates: mirror.team-cymru.org
Setting up Install Process
Package tkinter-2.6.6-36.el6.x86_64 already installed and latest version

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 赞皇县| 自贡市| 顺义区| 台南县| 顺平县| 上犹县| 福安市| 加查县| 南靖县| 昂仁县| 且末县| 托里县| 台南县| 三都| 沧源| 修文县| 玉林市| 休宁县| 镇雄县| 宁远县| 大方县| 遵化市| 句容市| 来宾市| 杭锦后旗| 盈江县| 双鸭山市| 通许县| 英山县| 固安县| 阜城县| 玉溪市| 安龙县| 阳泉市| 台北市| 青州市| 北宁市| 上蔡县| 黎平县| 稻城县| 阿克陶县|