我是先装好Python,后来要用到Tkinter才装的
1.安装Python2.6.1:
dumeifang@dumeifang-desktop:~$ su
Password:
root@dumeifang-desktop:/home/dumeifang#wgethttp://www.python.org/ftp/python/2.6.1/Python-2.6.1.tgz
--14:28:31--http://www.python.org/ftp/python/2.6.1/Python-2.6.1.tgz
=> `Python-2.6.1.tgz'
Resolving www.python.org... 82.94.164.162
Connecting to www.python.org|82.94.164.162|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13,046,455 (12M) [application/x-tar]
......
解压:tar xfz Python-2.6.1.tgz
切换目录:cd Python-2.6.1
configure: ./configure
编译:make
安装:make install
试一下能不能用:
root@dumeifang-desktop:/home/dumeifang/Python-2.6.1#exit
exit
dumeifang@dumeifang-desktop:~$python
Python 2.6.1 (r261:67515, Mar 31 2009, 14:49:24)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
2.安装Tkinter
root@dumeifang-desktop:/home/dumeifang#apt-get install python-tk
提示安装成功
进入Python查看是否能用:
dumeifang@dumeifang-desktop:~$ python
Python 2.6.1 (r261:67515, Mar 31 2009, 14:49:24)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 39, in
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
>>>
不能用
安装tcl/tk8.5.6
(1).安装tcl8.5.6
cd tcl8.5.6/unix
./configure --enable-gcc –enable-shared
make
sudo make install
(2).安装tk8.5.6
cd tk8.5.6/unix
./configure –enable-gcc –enable-shared –with-tcl=../../tcl8.5.6/unix
make
make时出现一堆错误:
‘TkWindow’ has no member named ‘dispPtr’
......
类似这些
在新得利软件包中把x11的devel包都选择安上,再回来make,编译成功
make install安装成功
修改Python-2.6.1/Modules/Setup.dist文件,将以下部分开启:
# *** 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/local/lib /
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:-I/usr/local/include /# *** Uncomment and edit to reflect where your X11 header files are:#-I/usr/X11R6/include /
......
# *** Uncomment and edit to reflect your Tcl/Tk versions:
-ltk8.5 -ltcl8.5 /
......
# *** Always uncomment this; X11 libraries to link with:
-lX11
使用make命令进行编译,出现以下错误:
Failed to find the necessary bits to build these modules:
_bsddb_hashlib_sqlite3
_sslbsddb185bz2
dbmgdbmreadline
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
从新得利软件包当中查找libssl-dev, libbz2-dev, libgdbm-dev, libreadline5-dev,libsqlite3-dev安装上
重新make,依然还有错误:
Failed to find the necessary bits to build these modules:
_bsddbbsddb185dbm
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
patch -p1 < python2.6-disable-old-modules.patch
再make,还有错误,抑郁:
Failed to find the necessary bits to build these modules:
_bsddbdbm
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
从新得利软件包中找到libdb4.4-dev装上,再make,这次编译终于通过了!
最后make install
检验一下:
dumeifang@dumeifang-desktop:~$ python
Python 2.6.1 (r261:67515, Mar 31 2009, 14:49:24)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>
成功,终于搞定!不容易呀!