Python upgrade hint Tkinter module could not find a workaround

Source: Internet
Author: User
Tags stdin python script

One, install Tkinter
in Linux, Python does not install the Tkinter module by default, and the
Copy code code is as follows:
[[email protected] ~]# python
python 2.6.6 (r266:84292, Feb, 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 <modul E>
Importerror:no module named Tkinter
>>>
We install Tkinter module
Copy code code as follows:
[[email  Protected] ~]# yum-y install Tkinter
...
[[email protected] ~]# python
python 2.6.6 (r266:84292, Feb, 00:00:18)
[GCC 4.4.7 20120313 (Red Ha T 4.4.7-3)] on linux2
Type ' help ', ' copyright ', ' credits ' or ' license ' for more information.
>>> import Tkinter
>>>
Second, the Python version of the upgrade Python
Linux is not called low by default
View Python version
Copy code code as follows:
[[ Email protected] ~]# python-v
Python 2.6.6

Down new version
Copy the code code as follows:
[Email protected] ~]# wget http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz

Unzip the installation
Copy the code code as follows:
[Email protected] ~]# TAR-XF python-2.7.4.tgz
[Email protected] ~]# CD Python-2.7.4
[Email protected] python-2.7.4]#./configure
...
[[email protected] python-2.7.4]# make
...
[[email protected] python-2.7.4]# make install
...

See if the new version of Python can use Tkinter? The
Copy code code is as follows:
[[[email protected] python-2.7.4]#./python
Python 2.7.4 (default, APR, 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.< br>>>> 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-up, in &L T;module>
    Import _tkinter # If This fails your Python * 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 the code code as follows:
[[email protected] 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 the code code as follows:
[email protected] 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 the code code as follows:
[Email protected] 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 the code code as follows:
[Email protected] python-2.7.4]# vim modules/setup.dist

Find the following lines and remove the number from the front to open it.
Copy the code code 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 the code code as follows:
[Email protected] python-2.7.4]# Rpm-qa | grep ^TK
Tk-8.5.7-5.el6.x86_64
Tkinter-2.6.6-36.el6.x86_64
[Email protected] 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 the code code as follows:
[Email protected] python-2.7.4]# yum-y install Tcl-devel tk-devel

Start Configuration installation
Copy code code as follows:
[[email protected] python-2.7.4]# ldconfig
[[email protected] Python-2.7.4 ]#./configure
...
[[email protected] python-2.7.4]# make
...
[[email protected] python-2.7.4]# make install
...

See if the new Python can use the Tkinter module
Copy the code code as follows:
[Email protected] 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 the code code as follows:
[Email protected] 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 the code code as follows:
[[email protected] python-2.7.4]# which Python
/usr/local/bin/python

CP Past
Copy the code code as follows:
[email protected] python-2.7.4]# CP Python/usr/local/bin/python

Four, upgrade python caused by the Yum version can not be used to solve the problem
many children's shoes after installation of the
Copy code code as follows:
CP Python/usr/bin/python
Cause yum When prompted
Copy code code as follows:
[[email protected] ~]# Yum
There is a problem importing one of the Python modules
required to run yum. The error leading to this problem is:
 
   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, 17:12:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
 
If You cannot solve this problem your Self, click Go to
the Yum FAQs at:
  http://yum.baseurl.org/wiki/Faq
  
 
[[email& Nbsp;protected] ~]#

Because Yum header defaults to the path of the Python script is
Copy the code code 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 the code code as follows:
#! /usr/bin/python2.6

Source Document

Python upgrade hint Tkinter module could not find a workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.