注意事项:直接在Linux系统中安装python3后会导致yum命令和pip命令失效。
安装python3过程(按下述方法安装依赖包、指定软链接,就不会出错了):
# 安装依赖包 yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel # 下载python3对应版本压缩包 wget https:///www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.gz # 解压 tar -xvf Python3.5.1.tar.gz # 安装 cd ./Python3.5.1 ./configure --prefix=/usr/local/bin/python3 make && make install #建立python3和pip3的软链接 ln -s /usr/local/bin/python3 /usr/bin/python ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
报错一: bash: yum:command not found...
方案:修改/usr/bin/yum文件的第一行,将结尾的python改成python27(或python2.7),请自行尝试,修改后能查询yum版本即可;
报错二:cannot retrieve matalink for repository:epel/x86...
方案:sed -i ‘s#https://#http://#g' /etc/yum.repos.d/epel*repo #将https改成http
报错三:使用yum install ***命令报错;
1 Downloading packages: 2 File "/usr/libexec/urlgrabber-ext-down", line 28 3 except OSError, e: 4 ^ 5 SyntaxError: invalid syntax
方案:修改/usr/libexec/urlgrabber-ext-down,将/usr/bin/python最后的python改成python2.7(或27),请自行尝试,修改成功执行yum install命令即可;
报错四:bash: pip: command not found...
方案:建立pip的软链接ln -s /usr/local/python3/bin/pip3 /usr/bin/pip