centos7源码安装python3.6.7
下载python3,官网地址:https://www.python.org/downloads/
找到对应的安装包,选择源码安装下载。
或者复制链接地址可以在命令行直接下载。
[root@hadoop tools]# wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz
安装依赖环境。
[root@hadoop 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
解压源码包,进入解压目录。
[root@hadoop tools]# tar -zxvf Python-3.6.7.tgz
……
[root@hadoop tools]# cd Python-3.6.7/
指定安装目录,进行编译安装。
[root@hadoop Python-3.6.7]# ./configure --prefix=/usr/local/python3
指定CPU核心数进行编译安装
[root@hadoop Python-3.6.7]# make -j `cat /proc/cpuinfo| grep "processor"| wc -l` && make install
进入python3环境进行简单测试。
[root@hadoop Python-3.6.7]# cd /usr/local/python3/bin/
[root@hadoop bin]# ./python3
Python 3.6.7 (default, Jan 21 2019, 10:20:03)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello word")
hello word
>>> print "hello word"
File "<stdin>", line 1
print "hello word"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("hello word")?
>>> quit()
此处说明python3环境已安装完成,因为python3已将print列为函数了,使用时必须添加圆括号。
建立软连接使其在其他目录也可以使用,但不能印象原来python的使用,因为原来的环境需要用到python2环境,比如yum。
[root@hadoop bin]# ln -s /usr/local/python3/bin/python3 /usr/bin/
配置环境变量
[root@hadoop bin]# vim /root/.bashrc
[code]# User specific environment and startup programs PATH=$PATH:$HOME/bin:/usr/local/python3/bin export PATH
[root@hadoop bin]# source /root/.bashrc
测试是否成功
[root@hadoop bin]# cd /root/
[root@hadoop ~]# python3
Python 3.6.7 (default, Jan 21 2019, 10:20:03)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
- centos7 nginx配置httpsCenos(6.6/7.1)下从源码安装Python+Django+uwsgi+nginx环境部署(二)
- centos7下源码安装python3.5.2
- Ubuntu 18.04.1 LTS版本卸载python3,源码安装python3.6.7
- centos上安装Python3.4——源码安装
- centos 服务器装与python34源码安装
- 64位Centos6.5使用源码安装Python3.5
- Centos7源码安装python3
- 在CentOS 7上安装Python3.5源码包
- CentOS源码安装Python3.6
- CentOS7源码安装Python3
- CentOS上从源码安装python
- centos 源码安装python3.5.1
- CentOS7.2 源码包编译安装Python3.6交互界面按Backspace键和方向键出现乱码
- 完美原创:centos7.1 从源码升级安装Python3.5.2
- CentOS 6.6源码安装Python 2.7
- 完美原创:centos7.1 从源码升级安装Python3.5.2
- Centos 7下源码安装python 3.6
- Centos7下源码编译安装python3.6
- CentOS 7.4 源码安装 Python3.6.3
- python之 centos6.7下 python 3.5.2 源码、Django-1.9 安装