您的位置:首页 > 运维架构 > Linux

CentOs安装Python3

2016-01-17 23:12 706 查看
1.首先,从sohu的镜像服务器上下载Python3.5的最新的源文件:

wget http://mirrors.sohu.com/python/3.5.1/Python-3.5.1.tgz[/code] 
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()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: