SoFunction
Updated on 2025-03-03

Detailed process of deploying a Python environment offline

1. Pre-work

1.1 Download address

/ftp/python/3.10.15/Python-3.10.

1.2 Installation system dependencies

# Installation dependenciesyum install -y gcc zlib-devel openssl-devel bzip2-devel
# If the above does not work, execute the following (Note: If there is no openssl-devel, you need to install it manually)yum install -y gcc zlib-devel openssl-devel bzip2-devel --nogpgcheck

2. Deploy Python

# Unzip and start compilingtar -zxvf $HOME/setup/Python-3.10. -C $HOME/setup
cd $HOME/setup/Python-3.10.15
# Start compiling and installing./configure --prefix=$HOME/python3.10.15 --enable-shared --enable-loadable-sqlite-extensions
make -j8
make altinstall

3. Test Python

$HOME/python3.10.15/bin/python3.10
# Solution: Configure environment variables/root/python3.10.15/bin/python3.10: error while loading shared libraries: 
libpython3..1.0: cannot open shared object file: No such file or directory

4. Configure the environment

echo "export LD_LIBRARY_PATH=\"$HOME/python3.10.15/lib:\$LD_LIBRARY_PATH\"" >> $HOME/.bashrc
echo "export PATH=\"$HOME/python3.10.15/bin:\$PATH\"" >> $HOME/.bashrc
source $HOME/.bashrc
# Create a soft connection (note the soft connection version)ln -s $HOME/python3.10.15/bin/python3.9 $HOME/python3.9.0/bin/python
ln -s $HOME/python3.10.15/bin/pip3.9 $HOME/python3.9.0/bin/pip

5. Verify Python

python -V
Python 3.10.15
pip -V
pip 56.2.3 from /root/python3.10.15/lib/python3.10/site-packages/pip (python 3.10)

This is the end of this article about offline deployment of Python environment. For more related content on offline deployment of Python environment, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!