笔记
linux常用命令
配源
centos7升级python3
shell学习资料
批量修改文件名称
linux字符串截取
-
+
首页
centos7升级python3
1. 安装编译 Python3的相关包 yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel 2. 安装pip(CentOS没有pip) # 添加 epel 扩展源 yum -y install epel-release # 安装 pip yum install python-pip # 安装pip3 yum install -y python3-pip 3. 用 pip 安装 wget pip install wget 4. 下载 python3.7的源码包 # wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz # 从华为云镜像站下载 wget https://mirrors.huaweicloud.com/python/3.7.2/Python-3.7.2.tgz 5. 编译生成python解释器 # 解压缩 tar -zxvf Python-3.7.2.tgz # 进入解压后的目录 cd Python-3.7.2 # 依次执行下面命令进行手动编译 ./configure prefix=/usr/local/python3 make && make install 6. 添加软链接 # 删除原来的 python 软链接 rm /usr/bin/python # 添加 python 的软链接 ln -s /usr/local/python3/bin/python3.7 /usr/bin/python # 添加 python3 的软链接 ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3.7 # 添加 pip3 的软链接 ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3.7 # 测试是否安装成功了 python -V 7. 更改yum配置 vi /usr/bin/yum 把 #! /usr/bin/python 修改为 #! /usr/bin/python2 vi /usr/libexec/urlgrabber-ext-down 把 #! /usr/bin/python 修改为 #! /usr/bin/python2 因为其要用到python2才能执行,否则会导致yum不能正常使用
admin
2023年5月25日 16:51
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码