Python Python3.9.2 Installation on EulerOS
- Check whether the Python development environment that meets the version requirements is installed. For details, see Checking the OS Requirements and Environment. This section uses Python 3.9.2 as an example.
Run the python3 --version command. If the command output meets the Python version requirements (3.9.0 to 3.9.2), skip this section. Otherwise, perform the following steps to install the required Python version:
- Install the yum dependencies.
sudo yum install -y make zlib-devel libffi-devel openssl-devel sqlite-devel
- Install Python 3.9.2.
- Run the wget command to download the source package of Python 3.9.2 to any directory on the AMCT server:
wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz
- Go to the download directory and decompress the source package:
tar -zxvf Python-3.9.2.tgz
- Go to the new folder and run the following configuration, compilation, and installation commands:
cd Python-3.9.2 ./configure --prefix=/usr/local/python3.9.2 --with-ssl-default-suites=openssl --enable-shared CFLAGS=-fPIC make sudo make install
The --prefix option specifies the Python installation path. You can change it as required. The --enable-shared option is used to compile the dynamic library.
This document uses --prefix=/usr/local/python3.9.2 as an example. After executing the above commands, find the installation package in the /usr/local/python3.9.2 directory.
- Set the Python 3.9.2 environment variables.
- If Python is installed by the root user:
AMCT is installed by the root user. Run the following commands in the current terminal window to set environment variables:
# Set the Python 3.9.2 library path. export LD_LIBRARY_PATH=/usr/local/python3.9.2/lib:$LD_LIBRARY_PATH # If multiple Python 3 versions exist in the user environment, specify Python 3.9.2. export PATH=/usr/local/python3.9.2/bin:$PATH
If the running user is the root user, it is not advised to modify the .bashrc file. Otherwise, the Python tools provided by other systems may be unavailable. If you want to use the default tool, open another terminal window.
- If Python is installed by a non-root user:AMCT is also installed by the non-root user. Run the vi ~/.bashrc command in any directory to open the .bashrc file, and append the following lines to the file:
# Set the Python 3.9.2 library path. export LD_LIBRARY_PATH=/usr/local/python3.9.2/lib:$LD_LIBRARY_PATH # If multiple Python 3 versions exist in the user environment, specify Python 3.9.2. export PATH=/usr/local/python3.9.2/bin:$PATH
Run the :wq! command to save the file and exit. Run the source ~/.bashrc command for the modification to take effect immediately.
- If Python is installed by the root user:
- Run the wget command to download the source package of Python 3.9.2 to any directory on the AMCT server:
- After the installation is complete, run the following commands to check the installed version. You should see the required version information if the installation is successful.
python3 --version pip3 --version