First, install the Tkinter
In Linux, Python does not install the Tkinter module by default.
Copy CodeThe code is as follows:
[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):
File " ", line 1, in
Importerror:no module named Tkinter
>>>
We install the Tkinter module
Copy CodeThe code is as follows:
[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
>>>
Second, upgrade Python
The Python version of Linux is not called low by default
View Python version
Copy CodeThe code is as follows:
[root@li250-193 ~]# Python-v
Python 2.6.6
Down new version
Copy CodeThe code is as follows:
[root@li250-193 ~]# wget http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz
Unzip the installation
Copy CodeThe code is as follows:
[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
...
See if the new version of Python can use Tkinter?
Copy CodeThe code is as follows:
[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):
File " ", line 1, in
File "/root/python-2.7.4/lib/lib-tk/tkinter.py", line.
Import _tkinter # If This fails your Python is not being configured for Tk
Importerror:no module named _tkinter
>>>
Are you prompted to find the Tkinter module? See if the old version is normal.
Copy CodeThe code is as follows:
[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
>>>
Old version of no problem, do you need yum install Tkinter once?
Copy CodeThe code is as follows:
[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
Nothing to do
Hint has been installed, it seems not tkinter problem, see Tkinter module where?
Copy CodeThe code is as follows:
[root@li250-193 python-2.7.4]# Find/usr-name *tkinter.so
/usr/lib64/python2.6/lib-dynload/_tkinter.so
Find one, in the 2.6 old version of the directory, is estimated because the new repository points to the problem. So read the Readme note carefully. Reconfigure the installation
third, the correct installation of the new Python
First modify the Setup.dist file
Copy CodeThe code is as follows:
[root@li250-193 python-2.7.4]# Vim Modules/setup.dist
Find the following lines and remove the number from the front to open it.
Copy CodeThe code is as follows:
_tkinter _tkinter.c tkappinit.c-dwith_appinit \
-l/usr/local/lib \
-i/usr/local/include \
-ltk8.5-ltcl8.5 \
-lx11
Line Fourth above
-ltk8.5-ltcl8.5 default is 8.2, please change the actual TCL/TK version of your system
Copy CodeThe code is as follows:
[Root@li250-193 python-2.7.4]# Rpm-qa | grep ^TK
Tk-8.5.7-5.el6.x86_64
Tkinter-2.6.6-36.el6.x86_64
[Root@li250-193 python-2.7.4]# Rpm-qa | grep ^TCL
Tcl-8.5.7-6.el6.x86_64
My system was loaded with 8.5, so I changed it to 8.5.
Save exit
Installing Tck-devel, Tk-devel
Copy CodeThe code is as follows:
[root@li250-193 python-2.7.4]# yum-y Install Tcl-devel tk-devel
Start Configuration Installation
Copy CodeThe code is as follows:
[root@li250-193 python-2.7.4]# Ldconfig
[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
...
See if the new Python can use the Tkinter module
Copy CodeThe code is as follows:
[root@li250-193 python-2.7.4]#./python
Python 2.7.4 (Default, APR 12 2013, 08:49:11)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import Tkinter
>>>
There's no problem, the old version look again.
Copy CodeThe code is as follows:
[root@li250-193 python-2.7.4]#/usr/bin/python2.6
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
>>>
It's okay.
If the direct-typing python-v view version is not up-to-date, if it is not possible to do so:
Which out the Python command path
Copy CodeThe code is as follows:
[root@li250-193 python-2.7.4]# which Python
/usr/local/bin/python
CP Past
Copy CodeThe code is as follows:
[root@li250-193 python-2.7.4]# CP Python/usr/local/bin/python
Four, upgrade Python cause the Yum version is not available to solve the problem
Many children's shoes after installation
Copy CodeThe code is as follows:
CP Python/usr/bin/python
Prompt when Yum is causing
Copy CodeThe code is as follows:
[Root@lee ~]# Yum
There was a problem importing one of the Python modules
Required to run Yum. The error leading to this problem was:
No module named Yum
Install a package which provides this module, or
Verify the module is installed correctly.
It ' s possible that the above module doesn ' t match the
Current version of Python, which is:
2.7.4 (Default, APR 9 2013, 17:12:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
If You cannot solve this problem yourself and go to
The Yum FAQ at:
Http://yum.baseurl.org/wiki/Faq
[Root@lee ~]#
Because Yum header defaults to the path of the Python script is
Copy CodeThe code is as follows:
#! /usr/bin/python
You replace the old version of Python is not used, do not know why the new version of Python can not be recognized by Yum, the only best solution now is to modify the Yum header statement
Change into
Copy CodeThe code is as follows:
#! /usr/bin/python2.6
Can, here python2.6 is my CentOS default version, everyone's default version is how many, please modify the actual situation