CentOs安装Python3

本文详细介绍了如何从搜狐镜像服务器下载 Python3.5 的最新源文件,并通过一系列步骤完成自定义路径安装的过程。具体步骤包括下载源文件、解压缩、配置安装路径等,最后验证安装是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.首先,从sohu的镜像服务器上下载Python3.5的最新的源文件:

wget http://mirrors.sohu.com/python/3.5.1/Python-3.5.1.tgz

2.解压

tar -xzvf Python-3.5.1.tgz

3.接下来就可以编译安装了,我想安装在自己指定的目录下,避免跟系统自带的Python2.6冲突。
进入解压后的Python-3.5.1目录,首先查看README文件,前面的介绍:

Build Instructions
------------------

On Unix, Linux, BSD, OSX, and Cygwin:

    ./configure
    make
    make test
    sudo make install

This will install Python as python3.

You can pass many options to the configure script; run "./configure --help" to
find out more.  On OSX and Cygwin, the executable is called python.exe;
elsewhere it's just python.

根据提示,执行./configure --help查看帮助:

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

根据提示,在./configure后面加上--prefix=$HOME应该就可以了。
4.完整的命令如下

./configure --prefix=/home/python3
make
make install

5.安装完检查一下python3目录:

[python3]$ ls
bin  include  lib  share

6.把python3/bin目录加到用户的PATH变量中。
7.测试一下:

[bin]$ python3
Python 3.5.1 (default, Jan 17 2016, 22:57:35) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值