Alpine Linux 安装 python3
1.进入容器内部, linux安装python3环境
root@cb8e397d5308:/var/jenkins_home# cd /var/jenkins_home/
root@cb8e397d5308:/var/jenkins_home# mkdir python3
root@cb8e397d5308:/var/jenkins_home# cd python3/
root@cb8e397d5308:/var/jenkins_home/python3# wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
root@cb8e397d5308:/var/jenkins_home/python3# tar -xvf Python-3.8.0.tgz
root@cb8e397d5308:/var/jenkins_home/python3# ls
Python-3.6.8 Python-3.6.8.tgz
root@cb8e397d5308:/var/jenkins_home/python3# cd Python-3.8.0
root@cb8e397d5308:/var/jenkins_home/python3/Python-3.8.0# ./configure --prefix=/var/jenkins_home/python3 --with-ssl
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.8... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/var/jenkins_home/python3/Python-3.6.8':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
报错安装依赖
2.解压,下载依赖
下载依赖
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
或
apk add build-base //install GCC on Alpine Linux, apk add是安装命令,不同Linux,命令不同
apk add zlib-dev //install zlib-devel
解压进入
tar xvf Python-3.8.0.tgz
cd Python-3.8.0
3.make编译安装
解压完之后需要编译Python-3.8.0包下的文件,先cd过去执行完这句命令之后,把python的安装目录指定一下,这样的话,里面的一些bin目录、lib目录就都会存放在这个目录下面。
如果不指定这个安装目录的话,最后python的安装文件将分散到linux的默认目录,不在一块。我们指定安装目录,以后卸载的话直接删除目录就可以干净卸载了。
./configure --prefix=/var/jenkins_home/python3 --with-ssl
make
make install
4.添加软连接
由于系统默认的python是指向python2,这里执行把新安装的python3.8指向给/usr/bin/python3就可以了
添加python3软链接
ln -s /var/jenkins_home/python3/bin/python3.8 /usr/bin/python3
添加pip3软链接
ln -s /var/jenkins_home/python3/bin/pip3 /usr/bin/pip3
5.检察环境
python3
pip3
参考链接:https://blog.csdn.net/weixin_38337769/article/details/105365207?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522159719962119724842923665%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=159719962119724842923665&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v3~pc_rank_v3-4-105365207.pc_ecpm_v3_pc_rank_v3&utm_term=docke+jenkins+python&spm=1018.2118.3001.4187