Linux傻瓜式七步完美安装Python3.7
2021-04-29 03:29
标签:默认 conf read sqli 还需 pip val 需要 连接 安装完之后可能导致yum不能用,报错为: 原因是我们把默认的python命令改成了python3(原来是python2),而yum命令依赖于python2运行 我们需要修改yum命令使用的python版本,原来使用的是默认的python(即python2),现在默认的python变成了python3,我们把它改成python2即可。 Linux傻瓜式七步完美安装Python3.7 标签:默认 conf read sqli 还需 pip val 需要 连接 原文地址:https://www.cnblogs.com/mayite/p/13232994.html1 安装依赖包
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 libffi-devel gcc
2 下载解压Python3.7
# 1 首先切换到桌面
cd /home
# 2 下载
wget http://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
# 3 解压
tar -xvf Python-3.7.1.tar.xz
# 4 切换目录
cd Python-3.7.1
3 执行配置文件,编译,安装
./configure --prefix=/usr/local/python37
make
make install
4 建立软连接
mv /usr/bin/python /usr/bin/python_bak
ln -s /usr/local/python37/bin/python3.7 /usr/bin/python
ln -s /usr/local/python37/bin/pip3.7 /usr/bin/pip
5 测试
# python
Python 3.7.1 (default, Jan 14 2019, 10:30:01)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world!")
hello world!
>>> exit()
# pip --version
pip 10.0.1 from /usr/local/python37/lib/python3.7/site-packages/pip (python 3.7)
6 产生问题
# yum -y install redis
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
7 解决方案
# 打开文件
vi /usr/bin/yum
# 修改第一行#!/usr/bin/python 改为#!/usr/bin/python2.7
# 还需要修改第二个文件
vi /usr/libexec/urlgrabber-ext-down
# 修改第一行#!/usr/bin/python 改为#!/usr/bin/python2.7
上一篇:JavaScript图片预览
下一篇:1_文件上传漏洞原理
文章标题:Linux傻瓜式七步完美安装Python3.7
文章链接:http://soscw.com/index.php/essay/80065.html