ubuntu安装python2_Ubuntu下安装Python2.6.1以及Tkinter | 学步园

我是先装好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

>>>

成功,终于搞定!不容易呀!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值