Debian 7 安装 Python3.4

摘要:
Debian 7中包含的python是2.7.3。如果我想使用最新版本3.4,该怎么办?1、 安装并编译包1$sudoapt getinstallbuild essential 2$sudoaptgetinstalllibncurses5-devlncursesw5-devlibreadline6-dev3$sudoa普特getinstalllibdb5.1-devlibgdbm-devlibsqlite3-devlibssl-dev4$sudoapt getinstalllibbz2-devlibexpat1-devlibzma-devzlib1g-dev2.下载压缩包wget-chttps://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz3、编译并安装1$cddownload/2$tar zxfPython-3.4.1.tgz3$cdPython-3.4.14$./configure--prefix=/opt/python-3.4.15$make6$sudomakeinstall7$cddownload/8$sudom rfPython-3.4.1#删除并解压缩目录。安装后,将python3添加到PATH中,打开~/。bashrc文件,然后添加:exportPATH=$PATH:/opt/python3.4.1/bin对于python 3,我们可以看到当前版本是3.4.1。

Debian 7 自带的python是2.7.3,要用最新的3.4版本怎么办?我们从官网下载压缩包自己编译。

一、安装编译用的包

1 $ sudo apt-get install build-essential
2 $ sudo apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev
3 $ sudo apt-get install libdb5.1-dev libgdbm-dev libsqlite3-dev libssl-dev
4 $ sudo apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev

二、下载压缩包

wget -c https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz

三、编译安装

1 $ cd download/
2 $ tar -zxf Python-3.4.1.tgz
3 $ cd Python-3.4.1
4 $ ./configure --prefix=/opt/python-3.4.1
5 $ make
6 $ sudo make install
7 $ cd download/
8 $ sudo rm -rf Python-3.4.1 #删除解压目录

安装好后把 python3 添加到PATH里,打开~/.bashrc 文件,在最后添加:

export PATH=$PATH:/opt/python-3.4.1/bin

保存后:

source .bashrc

在终端里输入 python3,可以看到现在的版本是3.4.1。

$ python3
Python 3.4.1 (default, Aug 11 2014, 01:23:53) 
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

2015.01.09 更新:

在make时出现这个提示:

# Substitution happens here, as the completely-expanded BINDIR
# is not available in configure
sed -e "s,@EXENAME@,/opt/python-3.4.2/bin/python3.4m," < ./Misc/python-config.in >python-config.py
# Replace makefile compat. variable references with shell script compat. ones; ->
sed -e 's,$(([A-Za-z0-9_]*)),${1},g' < Misc/python-config.sh >python-config
# On Darwin, always use the python version of the script, the shell
# version doesn't use the compiler customizations that are provided
# in python (_osx_support.py).
if test `uname -s` = Darwin; then 
cp python-config.py python-config; 
fi

按提示操作:

$ sed -e "s,@EXENAME@,/opt/python-3.4.2/bin/python3.4m," < ./Misc/python-config.in >python-config.py
$ sed -e 's,$(([A-Za-z0-9_]*)),${1},g' < Misc/python-config.sh >python-config

再make:

$ make

最后:

sudo make install

在编译安装python3.4.2时有这个提示:

INFO: Can't locate Tcl/Tk libs and/or headers

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_tkinter                                                       
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

解决办法:

sudo apt-get install python-tk tcl tk tcl-dev tk-dev 

--End--

免责声明:文章转载自《Debian 7 安装 Python3.4》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Jmeter系列(43)- 详解 Jmeter 图形化 HTML 压测报告之 Charts 模块html 窗口参数详解下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

python 读取串口数据常用函数及实例分析

前记: 人生苦短,我用python,python在做一些算法验证和接口验证方面,的确是非常的好用。读取串口经常用到,这里就做个总结,给自己和周围的人做个备忘吧。 函数解析: 初始化串口数据: importserial #Serial takes two parameters: serial device and baudrate ser = serial....

树莓派更换阿里云源

我的树莓派使用的jessie系统: 1、打开文件 sudo nano /etc/apt/sources.list 2、编辑文件 将原来的deb.......和deb-src......两行注释掉 或者直接在这两行修改 debhttp://mirrors.aliyun.com/raspbian/raspbian/jessie main contrib non...

shell中的dd命令使用详解

一、dd命令的解释 dd:用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换。 注意:指定数字的地方若以下列字符结尾,则乘以相应的数字:b=512;c=1;k=1024;w=2 参数注释: 1. if=文件名:输入文件名,缺省为标准输入。即指定源文件。< if=input file > 2. of=文件名:输出文件名,缺省为标准输出。即指...

python(元组)

元组 Python 的元组与列表类似,不同之处在于元组的元素不能修改。 元组使用小括号 ( ),列表使用方括号 [ ]。 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可 创建一个元组 A = (1,2,'python','happy') #括号内可不输入内容,即为空元组 B = 1,2,3,'nice'...

Python微信库:itchat

在论坛上看到了用Python登录微信并实现自动签到,才了解到一个新的Python库: itchat 库文档说明链接在这: itchat 我存个档在我网站(主要是我打开很慢),以便以后阅读。 0x01 Start 最简单的回复 通过如下代码,可以完成回复所有文本信息(包括群聊)。 import itchat from itchat.content impor...

Linux下NFS配置及远程挂载

NFS配置及远程挂载 NFS简介  NFS是Network File System的简写,即网络文件系统。NFS最早是由 Sun Microsystems 公司开发,并于1984年推出。NFS 是一种可分散式的网络文件系统,可以通过网络(一个局域网)使不同的机器、不同的操作系统,能够共享目录和文件,使客户端能通过网络访问并分享文件到位于服务端的磁盘中。NF...