企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Centos 7上安装Python3.x(单版本) Centos7默认安装的是2.7,这里选择安装使用Python3.6.3 - 安装python3 需要的依赖包 >yum install -y openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc cc - 下载python源码 >wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz - 解压和编译 ``` mkdir /usr/local/python3 -p tar xf Python-3.6.3.tgz cd Python-3.6.3 ./configure --prefix=/usr/local/python3 make make install ``` - 备份旧版python软链接,链接新版本python ``` [root@localhost ~]# ls -l /usr/bin/python lrwxrwxrwx. 1 root root 9 Oct 20 14:08 /usr/bin/python -> python2 [root@localhost ~]# ls -l /usr/bin/python2 lrwxrwxrwx. 1 root root 9 Oct 20 14:08 /usr/bin/python2 -> python2.7 [root@localhost ~]# ls -l /usr/bin/python2.7 -rwxr-xr-x. 1 root root 7136 Nov 5 2016 /usr/bin/python2.7 ``` ``` mv /usr/bin/python /usr/bin/python.bak ln -s /usr/local/python3/bin/python3 /usr/bin/python ln -s /usr/local/python3/bin/pip3 /usr/bin/pip ``` - 检验 Python 及 pip 版本 ``` [root@localhost ~]# python -V Python 3.6.3 [root@localhost ~]# pip -V pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6) ```