centos7搭建python3并和python2共存

2017-03-28  本文已影响0人  流弊的小白

1 注意事项:

# yum -y groupinstall "Development tools"
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

2安装

# wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tgz
# mkdir /usr/local/python3 
# tar -zxvf Python-3.4.2.tgz
# cd Python-3.4.2
# ./configure --prefix=/usr/local/python3
# make && make install
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3

3测试

# python3
Python 3.4.2 (default, Jul 19 2016, 03:47:32) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
#!/usr/bin/python3
# 第一个注释
print ("Hello, Python3!") 
执行
# python3 hello.py
Hello, Python3!
上一篇 下一篇

猜你喜欢

热点阅读