国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 湘阴县| 罗山县| 仙桃市| 江山市| 商洛市| 湖口县| 肇州县| 临城县| 夹江县| 庆安县| 都江堰市| 民权县| 黄骅市| 荣成市| 宁蒗| 逊克县| 定陶县| 嘉荫县| 高陵县| 安仁县| 汶上县| 固阳县| 萨迦县| 屏山县| 沭阳县| 年辖:市辖区| 高唐县| 钟山县| 墨竹工卡县| 惠安县| 宜城市| 五家渠市| 潼南县| 普安县| 武汉市| 衡阳县| 南城县| 丁青县| 文安县| 安庆市| 阿拉尔市|