部署Python3用于集群资源脚本调用
备注:在你使用的集群上都要做部署我这里默认bigdata241节点(检查节点上是否有git,没有的话yum下载)CentOS7 默认已经安装了Python2.7.5[root@bigdata241~]# python --versionPython 2.7.5[root@bigdata241 ~]# which python/usr/bin/python[root@bigd...
备注:在你使用的集群上都要做部署我这里默认bigdata241节点(检查节点上是否有git,没有的话yum下载)
CentOS7 默认已经安装了Python2.7.5
[root@bigdata241~]# python --version
Python 2.7.5
[root@bigdata241 ~]# which python
/usr/bin/python
[root@bigdata241 ~]#
CentOS7默认安装的Python2不能删除,因为有很多系统命令,比如yum都要用到。输
安装python3的方法(root 用户下)
(1).安装编译python需要的组件
# yum -y groupinstall "Development tools"
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
手动下载安装sqlite-devel
# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/sqlite-devel-3.7.17-8.el7.x86_64.rpm
# rpm -ivh sqlite-devel-3.7.17-8.el7.x86_64.rpm
在命令行下输入sqlite3如果可以看到如下信息,则说明安装成功,输入.quit退出
[root@bigdata241~]# sqlite3
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .quit 退出
(2).下载解压
# mkdir /usr/local/python3
# cd /usr/local/python3
# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
# tar -xvJf Python-3.6.5.tar.xz
(3). 编译安装
# cd Python-3.6.5
# ./configure --prefix=/usr/local/python3
# make && make install
说明:–prefix 后面指定安装目录,即刚刚创建的目录,笔者的是/usr/local/python3
然后创建软连接
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
(4).命令行输入python python3测试
[root@bigdata241 Python-3.6.5]# python
Python 2.7.5 (default, Jul 13 2018, 13:06:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@bigdata241 Python-3.6.5]#
注意:在编写python脚本时,注意python解释器的路径,python2为 #!/usr/bin/python,python3为#!/usr/bin/python3
更多推荐
所有评论(0)