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

    到此,安装成功
相关推荐
崇子嵘39 分钟前
基于zynqMPsoc15eg的linux端axi dma教训总结
linux·运维·服务器
qq_5137280440 分钟前
Alert 原生弹窗处理
python
李可以量化43 分钟前
Redis 从了解到精通(三)上:量化交易场景下的数据备份与安全配置
redis·python·安全·qmt·ptrade
卷无止境1 小时前
FastAPI查询参数模型:把散落的参数收拢成一个整齐的盒子
后端·python
动力 continue1 小时前
Linux 基础篇 · Vim 三种模式与常用指令
linux·运维·vim
Code额1 小时前
Python asyncio 异步编程全套学习文档(零基础完整版)
python·学习·oracle·async·异步·asyncio
钱栈up1 小时前
Mac 开发机一键发版不用切环境:我这样改造了团队的后端部署脚本
运维·python·mac
深念Y1 小时前
系统内存与Swap优化记录
linux·内存·优化·虚拟内存·压缩·ram·zram
funnycoffee1232 小时前
Huawei USG firewall no-nat config for ipsec traffic
linux·服务器