Cenos7+Git+Docker+Jenkins+Python持续集成:第二章 服务端python安装篇

1、以超级管理员进入Jenkins安装环境:docker exec -itu root 6efba52bdad1 ./bin/bash

  查看当前操作系统:cat /etc/issue

  

  Debian系统:使用apt-get替代yum进行文件下载 

 

 2、修改Debian 访问源文件

  Debian的源下载文件巨慢,需要修改为国内源,源文件是在Denbian系统中/etc/apt/sources.list中

  踩坑:应为安装Jenkins时下载的Debian的系统是非常纯净的,没有vi和vim等命令,无法编辑文件,所有需要将文件拷贝出来后,修改,在覆盖原文件

  docker-->centos7: docker cp 容器ID:/etc/apt/sources.list  /opt/sources.list

  centos7-->docker: docker cp /opt/sources.list  容器ID:/etc/apt/sources.list

腾讯镜像源:
deb https://mirrors.tencent.com/debian/ bullseye main non-free contrib deb-src https://mirrors.tencent.com/debian/ bullseye main non-free contrib deb https://mirrors.tencent.com/debian-security/ bullseye-security main deb-src https://mirrors.tencent.com/debian-security/ bullseye-security main deb https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib deb-src https://mirrors.tencent.com/debian/ bullseye-updates main non-free contrib deb https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib deb-src https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib
其他镜像源:Debian 11 (bullseye) 国内软件源 - Guanglin - 博客园 (cnblogs.com)

  

 

3、修改完成镜像源,更新命令:apt-get update

   

 

4、安装wget命令:apt-get install -y wget

  创建python3文件夹:mkdir /var/jenkins_home/python3

  

 

5、下载python包:wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz

   

 

6、解压下载的python包:tar -zvxf Python-3.6.8.tgz

  进入文件:cd /var/jenkins_home/python3

  执行命令:./configure --prefix=/var/jenkins_home/python3

  执行 ./configure --prefix=/var/jenkins_home/python3时报上面错:configure: error: no acceptable C compiler found in $PATH

 

 7、进入解压完成的文件中执行指令

  进入文件:cd /var/jenkins_home/python3/Python-3.6.8

安装gcc相关依赖包
apt-get -y install gcc automake autoconf libtool make
apt-get -y install make*
apt-get -y install zlib*
apt-get -y install openssl libssl-dev
apt-get install sudo

8、make编译安装

./configure --prefix=/var/jenkins_home/python3 --with-ssl
make
make install

9、添加软链接

添加python3软链接
ln -s /var/jenkins_home/python3/bin/python3 /usr/bin/python3
添加pip3软链接
ln -s /var/jenkins_home/python3/bin/pip3 /usr/bin/pip3

使用python3指令 检测
使用pip3指令 检测

 

踩坑:pip3检测: bash: pip3: command not found

      原因:pip3未安装

   解决方法:apt-get install python3-pip

posted @ 2022-03-30 00:30  youyouzipei  阅读(141)  评论(0)    收藏  举报