centos7升级python2到python3.6.8使用yum安装问题

背景

公司爬虫需要使用python3.6.8版本,因此升级centos的python2到python3.6.8。但是当使用yum安装包时 ,出现如下异常:

sh 复制代码
[root@localhost bin]# yum install npm -y
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-sclo-rh: mirrors.ustc.edu.cn
 * epel: mirror.01link.hk
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
  File "/usr/libexec/urlgrabber-ext-down", line 28
    except OSError, e:
                  ^
SyntaxError: invalid syntax
  File "/usr/libexec/urlgrabber-ext-down", line 28
    except OSError, e:
                  ^
SyntaxError: invalid syntax
  File "/usr/libexec/urlgrabber-ext-down", line 28
    except OSError, e:
                  ^
SyntaxError: invalid syntax
  File "/usr/libexec/urlgrabber-ext-down", line 28
    except OSError, e:
                  ^
SyntaxError: invalid syntax
  File "/usr/libexec/urlgrabber-ext-down", line 28
    except OSError, e:
                  ^
SyntaxError: invalid syntax

在网上搜索了一圈结果都是相互copy,因此,我就整合了各种处理方案进行解决。

解决
  • 1.查看当前系统版本
sh 复制代码
python -V
  • 2.查看yum使用的python版本并修改yum的python版本到2.7
sh 复制代码
cat /usr/bin/yum
vim /usr/bin/yum
  • 3.使用yum下载
sh 复制代码
yum install npm -y

仍然提示如下异常:

根据异常可以推断出应该也是python版本问题,因此,找到异常文件并修改python版本

sh 复制代码
cat /usr/libexec/urlgrabber-ext-down
vim /usr/libexec/urlgrabber-ext-down

修改:

  • 4.重新使用yum命令安装

    到此,安装成功
相关推荐
曲幽2 分钟前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
用户556918817532 小时前
#从脚本到独立程序:Python + Playwright 批量抓取的完整踩坑记录
python·自动化运维
兵慌码乱16 小时前
基于 MediaPipe 与 PySide2 的手势交互音乐控制系统实现:轻量化视觉交互全流程解析
python·opencv·计算机视觉·人机交互·手势识别·mediapipe·pyside2
luckdewei18 小时前
FastAPI 资产管理系统实战:复杂 ORM 关联、Alembic 迁移与 N+1 查询优化
python
aqi001 天前
15天学会AI应用开发(八)使用向量数据库实现RAG功能
人工智能·python·大模型·ai编程·ai应用
Csvn1 天前
`functools.lru_cache` —— 一行代码搞定缓存加速
后端·python
zzzzzz3101 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode1 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
金銀銅鐵2 天前
[Python] 从《千字文》中随机挑选汉字
后端·python