Installing Python
Python 3.9.9 is installed by default in openEuler 22.03 LTS SP3. However, TensorFlow 1.15.5 depends on Python 3.7.x. Therefore, you need to reinstall Python. This section describes how to install Python 3.7.5 using source code.
- Use PuTTY to log in to the server as the root user.
- Go to the compilation path for Python source code.
cd /path/to/python
- Install Python source code compilation dependencies.
yum install zlib-devel openssl-devel sqlite-devel xz-devel bzip2-devel libffi-devel
- Download the Python 3.7.5 source code to the server.
1wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz --no-check-certificate
- Decompress the Python 3.7.5 source package and go to the decompressed directory.
1 2
tar -zxvf Python-3.7.5.tgz cd Python-3.7.5
- Perform the configuration.
1./configure --prefix=/usr/local/python3.7.5 --enable-loadable-sqlite-extensions --enable-shared
- --prefix: specifies the Python installation path. Change the path as required. /usr/local/python3.7.5 is used as an example.
- --enable-shared: compiles the libpython3.7m.so.1.0 dynamic library and installs it in /usr/local/python3.7.5/lib/libpython3.7m.so.1.0.
- --enable-loadable-sqlite-extensions: loads the libsqlite3-dev dependency.
- Perform the compilation.
1make
- Perform the installation.
1make install - Configure Python 3 environment variables.
1 2
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH export PATH=/usr/local/python3.7.5/bin:$PATH
- View the installed versions.
1 2
python3 --version pip3 --version


If the correct versions are displayed, the installation is successful.
- Back up the original Python program and create a Python soft link.
1 2 3 4
mv /usr/bin/python /usr/bin/python_bk mv /usr/bin/pip /usr/bin/pip_bk ln -s /usr/local/python3.7.5/bin/python3 /usr/bin/python ln -s /usr/local/python3.7.5/bin/pip3 /usr/bin/pip
- View the installed versions.
1 2
python --version pip --version


If the correct versions are displayed, the installation is successful.
- Configure the pip repository and update pip.
1 2 3
pip3 config set global.index-url https://mirrors.huaweicloud.com/repository/pypi/simple pip3 config set global.trusted-host mirrors.huaweicloud.com pip3 install --upgrade pip
Parent topic: Configuring the Compilation Environment