Preface
In the previous article, we installed jenkins in docker, and running the jenkins working directory workspaces runs in the container, so if you execute python code, you need to install the python3 environment inside the container.
Enter pip3 when building, prompt: pip3: not found
Into the jenkins container
dock ps
Query the running container id
docker exec -it -u root e7d57efc9142 /bin/bash
docker exec -it -u root 容器id /bin/bash
View current operating systemcat /etc/issue
[root@VM_0_11_centos ~]# docker exec -it -u root e7d57efc9142 /bin/bash
root@e7d57efc9142:/# cat /etc/issue
Debian GNU/Linux 9 \n \l
What I found here is the Debian system (not ubuntu, nor centos), here yum is not available, so you can’t install it with yum, here use apt-get instead of yum
to update apt-get first
apt-get update
Install python3 environment inside the container
Enter the container working directory
cd /var/jenkins_home/
Create python3 file
mkdir python3
Enter the python3 directory
cd python3 /
Download python3 package
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
Unzip the downloaded tar package
tar -xvf Python-3.6.8.tgz
After decompression, you need to compile the files under the Python-3.6.8 package. After executing this command in the cd first, specify the python installation directory. In this case, some bin directories and lib directories inside will be stored in this directory the following.
If you do not specify this installation directory, the final python installation files will be scattered to the default directory of Linux, not together. We specify the installation directory, if you uninstall it later, you can directly delete the directory to uninstall cleanly.
./configure --prefix=/var/jenkins_home/python3
The ./configure --prefix=/var/jenkins_home/python3
above error was reported during execution : configure: error: no acceptable C compiler found in $PATH
apt-get install dependencies
This is because of the lack of gcc related dependencies, use apt-get instead of yum to install related dependencies
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
make compile and install
Execute make and make install in the /var/jenkins_home/python3/Python-3.6.8 directory to install
Add soft link
Add python3 soft link
find / -name python3
ln -s / var / jenkins_home / python3 / bin / python3 / usr / bin / python3
Add pip3 soft link
find / -name pip3
ln -s /var/jenkins_home/python3/bin/pip3 /usr/bin/pip3
Check the environment
Enter pip3 and python3 to check the environment
ssl problem
If you encounter ssl related issues when installing pip3: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
This is because of the lack of ssl dependency packages. The online solution is yum install openssl-devel
, because the Debian system does not have yum, install it with apt-get
After the installation is complete, only the pip installation problem corresponding to the python2 that comes with the system can be solved, but the pip3 installation problem of python3 cannot be solved.
Solution: add parameter --with-ssl when compiling above
Just re-execute make and make install