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

一、安装编译用的包

 $ sudo apt-get install build-essential
$ sudo apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev
$ sudo apt-get install libdb5.-dev libgdbm-dev libsqlite3-dev libssl-dev
$ 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

三、编译安装

 $ cd download/
$ tar -zxf Python-3.4..tgz
$ cd Python-3.4.
$ ./configure --prefix=/opt/python-3.4.
$ make
$ sudo make install
$ cd download/
$ sudo rm -rf Python-3.4. #删除解压目录

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

export PATH=$PATH:/opt/python-3.4./bin

保存后:

source .bashrc

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

$ python3
Python 3.4. (default, Aug , ::)
[GCC 4.6.] 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的更多相关文章

  1. 在阿里云CentOS服务器上安装Python3.7并设置为默认Python

    1.引言 Linux操作系统自带一个python2.7,没有python3,在开发的时候非常不便,因此需要安装一个python3,并且将python3设置系统默认python,同时还不能影响那些Lin ...

  2. Jenkins(2)docker容器中安装python3

    前言 使用docker安装jenkins环境,jenkins构建的workspace目录默认是在容器里面构建的,如果我们想执行python3的代码,需进容器内部安装python3的环境. 进jenki ...

  3. jenkins容器内安装python3

    前言 很多小伙伴可能在考虑 jenkins 拉取了 github 上的代码后,发现还越少 python3 环境,那能怎么办呢? 咨询了一位运维朋友给我的答案是,将 python3 挂载到容器工作目录上 ...

  4. 在 Debian 上安装 SQL Server vNext CTP1

    微软在开源 .NET Framework 之后,相继推出了跨平台的编辑器 Visual Studio Code,跨平台的 SQL Server 数据库 SQL Server vNext,Visual ...

  5. centos6安装python3.4和pip3

    在安装了epel源的情况下,直接yum就可以安装python3.4 yum install python34 -ypython3 --version 没有自带pip3,从官网安装 wget --no- ...

  6. 在CentOS6.8上面安装Python3.5

    以前每次装Linux,升级Python,都会一堆问题,然后Google,本来想着记录一下,结果问题太多了,也就记不住了,这次特地记了下来. 在CentOS6.8上面安装Python3.5我的系统是Ce ...

  7. python3.5学习笔记:linux6.4 安装python3 pip setuptools

    前言: python3应该是python的趋势所在,当然目前争议也比较大,这篇随笔的主要目的是记录在linux6.4下搭建python3环境的过程 以及碰到的问题和解决过程. 另外,如果本机安装了py ...

  8. 在Ubuntu中安装Python3

    首先,通过命令行安装Python3.2,只需要在终端中通过命令行安装即可: sudo apt-get install python3   一路yes. 因为Ubuntu很多底层采用的是Python2. ...

  9. python环境搭建-在Windows上安装python3.5.2

    在Windows上安装Python3.5.2 首先,根据你的Windows版本(64位还是32位)从Python的官方网站下载Python 3.5.2对应的64位安装程序或32位安装程序(网速慢的同学 ...

随机推荐

  1. CSS基础(背景、文本、列表、表格、轮廓)

    CSS 背景属性 属性 描述 background 简写属性,作用是将背景属性设置在一个声明中. background-attachment 背景图像是否固定或者随着页面的其余部分滚动. backgr ...

  2. 举例详细说明javascript作用域、闭包原理以及性能问题(转)

    转自:http://www.cnblogs.com/mrsunny/archive/2011/11/03/2233978.html 这可能是每一个jser都曾经为之头疼的却又非常经典的问题,关系到内存 ...

  3. 一个通用的Makefile (转)

    据http://bbs.chinaunix.net/thread-2300778-1-1.html的讨论,发现还是有很多人在问通用Makefile的问题,这里做一个总结.也作为以后的参考.       ...

  4. DelphiXE8怎么使用调试模式

    需求:在开发Android程序时,大家一直是使用ShowMessage.其实XE是支持下断点的. 操作: 1.小米手机用USB线,连到电脑上. 2.小米手机-设置-关于手机-"MIUI版本& ...

  5. codeforces 630J Divisibility

    J. Divisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard in ...

  6. js获取服务端IP及端口及协议

    alert("location:"+window.location); alert("href: "+window.location.href); alert( ...

  7. CSS3教程:Transform的perspective属性设置

    1 2   <div id="animateTest" style="-webkit-transform: perspective(400px) rotateY(4 ...

  8. PC/UVa 题号: 110105/10267 Graphical Editor (图形化编辑器)题解

    #include<cstdio> #include<iostream> #include<string> #include<algorithm> #in ...

  9. C++转义字符使用

    编码过程中字符串可能过长,这通常须要换行,对于换行转义字符\ ,使用时要保证\后无空格,否则会出现"error C2017:非法的转义字符 "错误 如 //  ''\"后 ...

  10. iOS开发笔记系列-基础6(预处理程序)

    预处理程序提供了一些工具,使用这些工具更易于开发.阅读.修改程序,也易于将程序移植到不同的系统中.又称为宏. #define #define语句的基本用途之一就是给富豪名称指定程序常量.比如: #de ...