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命令安装

    到此,安装成功
相关推荐
爱吃辣椒的小豆豆23 分钟前
Linux-sshd-实战-白名单与跳板机
linux·运维·服务器
薛定猫AI23 分钟前
【技术干货】多AI团队大模型协作编排与编程项目评测架构解析
python·机器学习·ai·大模型·技术实战
外收内放24 分钟前
数据分析(图表信息详解)
python·学习·数据分析·matplotlib
气质、小青年!28 分钟前
进程1学习
linux·学习
blueSatchel1 小时前
framebuffer注册源码解读
linux·嵌入式
1-1=01 小时前
Python3 开发环境
python
2401_862880821 小时前
嵌入式Linux系统移植与驱动开发完整指南
linux·c语言·驱动开发
坤坤子吖1 小时前
Linux 线程同步与互斥——互斥锁
linux·服务器·c++·笔记·学习
miofly1 小时前
GitHub 今日推荐|MOSS-Image:靠坐标框精确控制文字排版的图像生成模型
python·开源·github
Tiandaren1 小时前
么是agent、为什么要做agent、怎么做agent、怎么工程化
人工智能·python·深度学习·大模型