Install Python 3 on CentOS 6.5

Install Python 3 on CentOS 6.5

  • 1. check python version on current Linux OS and download Python3 source code package
  • 2. setup compilation、 make、make install
  • 3. create a link to python 3

Existing Python Packages

You may already have Python installed on your server, you can verify using:

[rainbow@master Desktop]$ which python
/usr/bin/python
[rainbow@master Desktop]$ python --version
Python 2.6.6
[rainbow@master Desktop]$ python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Download Python 3

First, visited python web and download source code package that you want to use, for this example I’m downloading the latest stable version 3.4.3:
https://www.python.org/downloads/ [ download page ]

Install Python 3

Next, go to the download directory and extracted package

[rainbow@master ~]$ cd Downloads/
Python-3.4.3.tgz
[rainbow@master ~]$ tar -xvf Python-3.4.3.tgz
[rainbow@master ~]$ ls
 Python-3.4.3
 Python-3.4.3.tgz

then, go to the extracted Python directory:

[rainbow@master ~]$ cd Python-3.4.3
[rainbow@master Python-3.4.3]$ ls
build          Include          Misc            python
config.guess   install-sh       Modules         Python
config.log     Lib              Objects         python-config
config.status  libpython3.4m.a  Parser          python-config.py
config.sub     LICENSE          PC              python-gdb.py
configure      Mac              PCbuild         README
configure.ac   Makefile         pybuilddir.txt  setup.py
Doc            Makefile.pre     pyconfig.h      Tools
Grammar        Makefile.pre.in  pyconfig.h.in

Then setup compilation:

[rainbow@master Python-3.4.3]$ ./configure

Note: If you receive the error: configure: error: no acceptable C compiler found in $PATH during this step, run this command before configuring:

[rainbow@master Python-3.4.3]$ yum install gcc

Then build:

[rainbow@master Python-3.4.3]$ make

And install:

[rainbow@master Python-3.4.3]$ make install

Next, verify Python 3 installation:

[rainbow@master Python-3.4.3]$ /usr/local/bin/python3 --version
Python 3.4.3
[rainbow@master Python-3.4.3]$ ln -s /usr/local/bin/python3 /usr/bin/python3

And check:

[rainbow@master Python-3.4.3]$ python3 --version
Python 3.4.3
[rainbow@master Python-3.4.3]$ python3
Python 3.4.3 (default, Jun 18 2015, 16:32:03) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Now Python 3 is successfully installed and working.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值