当前位置: 首页 > news >正文

Centos6.4升级Python的曲曲折折

配置Jumpserver连接一台老的centos,配置账号后测试连接提示错误:
fatal: [网络检测服务器(root)]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "ansible-core requires a minimum of Python2 version 2.7 or Python3 version 3.5. Current version: 2.6.6 (r266:84292, Feb 22 2013, 00:00:18) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]"}

原来是Python版本太老,需要升级Python。
1.下载遇到错误
wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
正在解析主机 www.python.org... 151.101.128.223, 151.101.0.223, 151.101.192.223, ...
正在连接 www.python.org|151.101.128.223|:443... 已连接。
OpenSSL: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
无法建立 SSL 连接。
下载错误,那就是手工下载,然后上传到服务器。

2.安装遇到错误一
--解压缩并安装
tar -zxvf Python-2.7.6.tgz && cd Python-2.7.6 && ./configure && make all && make install && make clean && make distclean
configure: error: in `/tmp/Python-2.7.6':
configure: error: no acceptable C compiler found in $PATH
原因是缺少gcc,那就安装

--安装
[root@Cnyunwei Python-2.7.6]# yum install gcc -y
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was 14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot find a valid baseurl for repo: base
--查看版本
[root@Cnyunwei Python-2.7.6]# cat /etc/issue
CentOS release 6.4 (Final)

--修改配置
[root@Cnyunwei Python-2.7.6]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[root@Cnyunwei Python-2.7.6]# cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak
[root@Cnyunwei Python-2.7.6]# vi  /etc/yum.repos.d/CentOS-Base.repo
[root@Cnyunwei Python-2.7.6]# vi /etc/yum.repos.d/epel.repo
主要是注释#mirrorlist修改baseurl
改了好几个地址都解决不了这个错误,一直报错。
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
直到最后找到这个才搞定
https://www.cnblogs.com/besehen/p/14914160.html

3.安装遇到错误二
继续进行安装
[root@Cnyunwei Python-2.7.6]#./configure && make all && make install && make clean && make distclean
又出现新错误:
-bash: make: command not found
You have mail in /var/spool/mail/root
还是和gcc有关

[root@Cnyunwei Python-2.7.6]# yum -y install gcc gcc-c++ automake autoconf libtool make
再安装python
[root@Cnyunwei Python-2.7.6]#./configure && make all && make install && make clean && make distclean
成功安装
python安装成功后,重新启动。
[root@Cnyunwei ~]# python --version
Python 2.7.6
Python升级成功

4.配置出现新错误:ansible.legacy.setup
fatal: [网络检测服务器]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "msg": "ansible-core requires a minimum of Python2 version 2.7 or Python3 version 3.5. Current version: 2.6.6 (r266:84292, Feb 222013, 00:00:18) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]"}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}
ansible.legacy.setup安装失败
奇怪,好像Jumpserver找到的还是老版本的Python,ansible.legacy.setup失败估计还是和Python有关系,继续排查。

[root@Cnyunwei etc]# ls -al /usr/bin |grep python
-rwxr-xr-x.  2 root root      4864 2月  22 2013 python
lrwxrwxrwx.  1 root root         6 8月   3 2017 python2 -> python
-rwxr-xr-x.  2 root root      4864 2月  22 2013 python2.6

报错里面解析python的路径是:{"discovered_interpreter_python": "/usr/bin/python"},可以把软链接改掉试试。

--python的安装路径
[root@Cnyunwei etc]# whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python /usr/local/bin/python2.7 /usr/local/bin/python2.7-config /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
--原来的软链接改名
[root@Cnyunwei etc]# mv /usr/bin/python /usr/bin/python.bak
You have mail in /var/spool/mail/root
[root@Cnyunwei etc]# ls -al /usr/bin |grep python
lrwxrwxrwx   1 root root        24 10月 17 13:33 python -> /usr/local/bin/python2.7
lrwxrwxrwx.  1 root root         6 8月   3 2017 python2 -> python
-rwxr-xr-x.  2 root root      4864 2月  22 2013 python2.6
-rwxr-xr-x.  2 root root      4864 2月  22 2013 python.bak

再次再Jumpserver服务器中测试连接。
2024-10-17 13:34:49 ok: [网络检测服务器]
2024-10-17 13:34:49
PLAY RECAP *********************************************************************
网络检测服务器                    : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
2024-10-17 13:34:49 Task assets.tasks.ping.test_assets_connectivity_task[9017479b-d7c4-4eb5-8049-c78e8a7dbd43] succeeded in 3.826504456810653s: None
OK.
 


http://www.mrgr.cn/news/52355.html

相关文章:

  • 上海数据集团到访蓝象智联 探讨数据基础设施建设
  • Python必知必会:15个Python字符串格式化技巧!
  • 前端工具函数库
  • <el-input-number> 回车自动失去焦点
  • 学习文档10/17
  • 2024年100道最新软件测试面试题,常见面试题及答案汇总
  • Python中cls是什么?
  • gsd ijhdsuif hdsuhf u
  • java算法OJ(4)树与二叉树
  • 读论文框架
  • 离线数仓(2)
  • 浅谈SpringBoot读取application配置文件流程
  • Whisper 音视频转写
  • 5个免费下载高清无水印带货短视频素材的网站推荐
  • linuxC读取bin文件
  • Spring 事务支持
  • python 爬虫 入门 一、基础工具
  • Rotary Position Embedding(RoPE)在视觉Transformer中的应用与提升
  • 两个案例全面阐述全链路测试怎么做
  • JAVA封装和包