下载安装ansible后,缺失pyyaml,pip安装时又出错,升级时又由于时Python2.7,不好升级遇到的一系列问题。

news2024/11/16 0:56:13

经过上一篇文章,我虽然误删了CentOs自带的python和yum,但是我重新将他们恢复了。这里记住默认的python版本是2.7.5。

我使用yum安装好ansible后,检查我的ansible版本的时候,发生了错误,提示没有yaml模块。

1 验证ansible时出错

yum install ansible
[root@yj test]# ansible --version
Traceback (most recent call last):
  File "/usr/bin/ansible", line 62, in <module>
    import ansible.constants as C
  File "/usr/lib/python2.7/site-packages/ansible/constants.py", line 19, in <module>
    from ansible.config.manager import ConfigManager, ensure_type, get_ini_config_value
  File "/usr/lib/python2.7/site-packages/ansible/config/manager.py", line 17, in <module>
    from yaml import load as yaml_load
ImportError: No module named yaml

2 pip安装包时出错

然后我看了网上的教程,提示使用pip去安装pyyaml模块,但是又报错了。

pip install pyyaml
Collecting PyYAML
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out. (read timeout=15)",)': /simple/pyyaml/
  Could not fetch URL https://pypi.python.org/simple/pyyaml/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618) - skipping
  Could not find a version that satisfies the requirement PyYAML (from versions: )
No matching distribution found for PyYAML

 这个之后,我尝试了很多种方法,都不成功,然后我把目光瞄准了是否是我的pip有问题。我开始使用pip --version,查看我的pip版本,到达目标位置除时,我发现这个pip时2019年的。这个肯定太老了。

[root@yj test]# pip --version
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

3 命令升级pip时出错。

下一步,我尝试去升级pip的版本。但是我发现使用命令去升级版本也会出错,也不行,下面是我的一系列尝试,最终还是以失败告终。

[root@yj test]# pip install --upgrade pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618) - skipping
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages
You are using pip version 8.1.2, however version 24.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@yj test]# pip install --upgrade --trusted-host  pip
You must give at least one requirement to install (see "pip help install")
You are using pip version 8.1.2, however version 24.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@yj test]# sudo pip install --upgrade --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages
You are using pip version 8.1.2, however version 24.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@yj test]# sudo python -m pip install --upgrade --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f107f4bad90>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/pip/
Collecting pip
  Downloading https://files.pythonhosted.org/packages/4d/87/fb90046e096a03aeab235e139436b3fe804cdd447ed2093b0d70eba3f7f8/pip-24.2.tar.gz (1.9MB)
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 307, in run
    requirement_set.prepare_files(finder)
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 370, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 587, in _prepare_file
    session=self.session, hashes=hashes)
  File "/usr/lib/python2.7/site-packages/pip/download.py", line 811, in unpack_url
    hashes=hashes
  File "/usr/lib/python2.7/site-packages/pip/download.py", line 650, in unpack_http_url
    hashes)
  File "/usr/lib/python2.7/site-packages/pip/download.py", line 892, in _download_http_url
    _download_url(resp, link, content_file, hashes)
  File "/usr/lib/python2.7/site-packages/pip/download.py", line 596, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "/usr/lib/python2.7/site-packages/pip/utils/hashes.py", line 49, in check_against_chunks
    for chunk in chunks:
  File "/usr/lib/python2.7/site-packages/pip/download.py", line 564, in written_chunks
    for chunk in chunks:
  File "/usr/lib/python2.7/site-packages/pip/utils/ui.py", line 139, in iter
    for x in it:
  File "/usr/lib/python2.7/site-packages/pip/download.py", line 553, in resp_read
    decode_content=False):
  File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 353, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 320, in read
    flush_decoder = True
  File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 242, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
You are using pip version 8.1.2, however version 24.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@yj test]# pip --version
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

4 手动升级pip

最后,我去尝试手动升级pip,去手动下载pip的安装包。查询到需要去pip网站上根据上面的教程来下载。

网址:pip · PyPI

但这个时候,因为我的python只有2.7.5,第一感觉我不可能去下载最新版本的pip,于是我想去找python和pip版本的对应关系,但是没有找到,于是我试着去官网找老一点的版本的pip先尝试一下,我惊奇地发现,官方竟然只提供了最新版本地pip地安装脚本get-pip.py。虽然我可以点击老版本,进入对应地下载页面,但当我进入老版本地下载页面点击Installgration地时候,总会跳转到最新版本地下载页面。如下所示。

跳转到

于是我实在没有办法了,就试着下载这最新版本地pip脚本到我的linux服务器中执行。果不其然,报错了,显示最新版本的pip最低支持的python版本时3.8,我的python版本太低了,但是我没有注意后面的提示,我就去重新找了很多办法都没成功。

 偶然间,我看到了提示,我惊喜地点进去,果然那个脚本和最新版本地pip的安装脚本不一样,于是我赶紧操作进行最后的安装。

Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead
[root@yj test]# python get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f9f749ab5d0>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/pip/
Collecting pip<21.0
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f9f73d01490>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /packages/27/79/8a850fe3496446ff0d584327ae44e7500daf6764ca1a382d2d02789accf7/pip-20.3.4-py2.py3-none-any.whl
  WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f9f73d01690>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /packages/27/79/8a850fe3496446ff0d584327ae44e7500daf6764ca1a382d2d02789accf7/pip-20.3.4-py2.py3-none-any.whl
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 193 kB/s 
Collecting wheel
  Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, wheel
  Attempting uninstall: pip
    Found existing installation: pip 8.1.2
    Uninstalling pip-8.1.2:
      Successfully uninstalled pip-8.1.2
Successfully installed pip-20.3.4 wheel-0.37.1
[root@yj test]# pip --version
pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)

终于成功了,最后yaml模块也正常安装了,运行ansible --version也正确运行了。总算把这个问题给解决了!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1988671.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

js事件循环机制(宏微任务队列都是先进先出)

文章目录 1.什么是事件循环2.主线程、任务队列、同步任务、异步任务、微任务、宏任务&#xff08;1&#xff09;主线程&#xff08;2&#xff09;同步任务&#xff08;3&#xff09;异步任务&#xff08;微任务、宏任务&#xff09;&#xff08;4&#xff09;任务队列 3.执行流…

乔布斯对产品,团队,人才的理解

乔布斯的设计理念和管理理念是他领导Apple取得成功的核心因素。以下是对他在产品设计和团队管理方面理念的详细描述 乔布斯的设计理念 1. 简约主义 简洁与直观&#xff1a;乔布斯强调设计的简约性。他相信产品应该尽可能简单且易于使用&#xff0c;去除一切不必要的复杂性。例如…

AIoT新技术融合基础设计课程开发与运营案例分析

本文来自下面的论文的第4部分&#xff1a;《Research on Basic Engineering Design Course Development and Application of New Technology AIoT (Artificial Intelligence of Things) Convergence Education》&#xff0c;作者是Yunja Hwang&#xff0c;来自韩国檀国大学工学…

IDEA左下角不显示本地修改的localChanges信息-git

IDEA左下角不显示本地修改的localChanges信息-git 取消勾选这个

【RTT-Studio】详细使用教程十:TM1638驱动数码管

文章目录 一、简介二、TM1638地址组三、TM1638的两种数码管使用方式四、TM1638数据格式五、按键扫描和键扫复用六、完整代码 一、简介 TM1638是深圳市天微电子有限公司设计的一款带键盘扫描接口的LED&#xff08;发光二极管显示器&#xff09;驱动控制专用芯片&#xff0c;内部…

React18+Vite+Eectron从入门到实战系列之一环境安装篇

如果我们的技术栈是react&#xff0c;也想要用electron来开发一个桌面的多端应用该怎么做呢&#xff1f;这篇文章选择了react的技术栈&#xff0c;讲解了环境的初始化步骤 实现效果 步骤 创建 react 项目 npm create vitelatest my-react-app安装依赖 cd my-react-app npm i…

勒索软件、供应链攻击等带来的思考!

2023年勒索软件、供应链攻击、地缘政治冲突与黑客活动主义、国家黑客间谍与APT组织活动成为网络安全的热点话题&#xff0c;生成式人工智能技术的武器化更是给动荡的全球网络安全威胁态势增加了不确定性、不对称性和复杂性。 即将到来的2024年&#xff0c;随着网络犯罪的规模化…

基于卷积神经网络ResUnet 多模态融合实验、BraTS 3d数据集(nii.gz)4模态融合分割

1、前言 之前介绍了unet对BraTS 3d数据集的2d图片分割&#xff0c;实现思路如下&#xff1a; 1、对BraTS 3d数据集进行切片&#xff0c;沿着某个模态的横断面切割 2、划分数据集、包括训练集、验证集等等 3、网络训练 4、评估模型性能等等 具体的可以参考本文&#xff1a;…

黑丝或者白丝,都可以用LoRA(Stable Diffusion进阶篇:ComfyUI 附加网络)

前言 在学习WebUI的那些基础知识点的时候&#xff0c;有一个东西是每一个初学者都绕不开的大山-附加网络。 这个东西对于每一个接触Stable Diffusion的小伙伴来说就像是小学门口小卖部卖的辣条、初中课本上的涂鸦、高中数学卷解不开的最后一道大题。 学习过WebUI里Stable Di…

基础岛 - 8G显存验证书生·浦语大模型的Demo

因为以前用过LMDeploy&#xff0c;所以本章的内容相对熟悉。 另外&#xff0c;因为教程写的很详细保姆级&#xff0c;所以大多数情况直接复制执行命令即可。开发机的创建略过。 总体验证结论&#xff1a; LMDeploy的模型加载有点慢&#xff0c;但推理速度快&#xff0c;符合预…

将tsx引入vue

按钮 vue <cl-batch-btn >新增批量</cl-batch-btn> import batch from "//modules/ad/components/ uploading/batch.vue" import ClBatchBtn from "/~/crud/src/components/batch-btn"; tsx

从困境到突破,EasyMR 集群迁移助力大数据底座信创国产化

在大数据时代&#xff0c;企业对数据的依赖程度越来越高。然而&#xff0c;随着业务的不断发展和技术的快速迭代&#xff0c;大数据平台的集群迁移已成为企业数据中台发展途中无法回避的需求。在大数据平台发展初期&#xff0c;国内数据中台市场主要以国外开源 CDH、商业化 CDP…

JVM(十二)细谈JVM类加载的各个过程以及如何修改Java原生API

本文深入探讨了Java虚拟机&#xff08;JVM&#xff09;的类加载机制&#xff0c;包括类的加载、验证、准备、解析和初始化等过程。文章首先通过几个高级面试问题引入主题&#xff0c;然后详细解释了JVM类加载的五个阶段及其重要性。接着&#xff0c;介绍了Java的三个主要类加载…

普通话测试前如何抱佛脚拿高分

全国普通话水平测试对很多大学生而言是最好拿证的考试&#xff0c;当然了对于某些专业的考生也会有更高的拿证要求&#xff0c;例如对于需要考教师资格证的同学而言。希望这篇文章可以帮助到各位考生在普通话水平测试中取得高分。 首先我们需要知道考试考什么 一、测试内容 …

M.2接口

接口分类 key-a key-b key-e key-m接口图片

图吧工具箱:硬件检测的一站式解决方案,好用到让同行都点赞!

前言 嘿&#xff0c;各位硬件迷们&#xff0c;小江湖又来啦&#xff01;今天&#xff0c;我手里可是攥着个宝贝&#xff0c;一个能让你们眼前一亮的神秘工具箱&#xff1b;别急着问是啥&#xff0c;我先卖个关子&#xff0c;就说这工具箱啊&#xff0c;简直是硬件界的“八卦炉”…

8.C基础_指针基础

指针概述 指针存放的都是首地址。 1、定义与初始化 形式&#xff1a;<数据类型>* <变量名> <地址>; int a 10; int *p &a; 指针的类型不同&#xff0c;p时的偏移地址量不同&#xff0c;偏移地址 sizeof(类型)Byte 注意点&#xff1a; 指针的…

LMS4124R-13000S01激光测距仪使用方法【sick LMS4124R-13000S01】

1、下载SOPAS&#xff1a; 点击下载SOPAS 1 SOPAS 自动搜索设备 正常上电及网络连接&#xff0c;打开 SOPAS 自动搜索到 LMS41XXX&#xff0c;并且可以看到其版本号&#xff0c; SN,IP 信息&#xff0c;产品默认 IP 为 192.168.0.1. 2 搜索设备 鼠标双击“LMS41XXX(SN 18460…

15.DMDIS 工具优化

文章目录 前言一、安装部署安装数据源转换作业监控 二、性能优化问题 1 &#xff1a;DMETL 卡顿问题问题 2 &#xff1a;DM -> HIVE 的迁移速度慢问题 3 &#xff1a;ORACLE -> DM 的迁移速度慢问题 4 &#xff1a;GP -> DM 的迁移速度慢问题 5 &#xff1a;DM -> …

AI芯片成本压力影响利润

Supermicro&#xff08;SMCI&#xff09;近日公布的季度业绩低于预期&#xff0c;主要因其生产的最新人工智能&#xff08;AI&#xff09;芯片服务器成本高企&#xff0c;导致经调整后的毛利率未能达到分析师的预期水平。这一消息使得其股价在盘后交易中急剧下跌14%&#xff0c…