Installing Python

Introduction

Currently, the Vision SDK package depends on Python. If Python is not configured in the environment, perform the following steps to install it. The following describes how to install Python 3.9.2 as the root user.

Procedure

  1. Install the Python 3.9.2 dependencies. The following uses Ubuntu as an example:
    1
    apt-get install -y build-essential gcc g++ make cmake zlib1g zlib1g-dev libsqlite3-dev openssl libssl-dev libffi-dev unzip pciutils net-tools libblas-dev gfortran libblas3 libopenblas-dev
    
  2. Download the Python 3.9.2 source installation package.
    1
    wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz
    
  3. Decompress the Python 3.9.2 installation package.
    1
    tar -zxvf Python-3.9.2.tgz --no-same-owner
    
  4. Compile and install Python 3.9.2.
    1
    cd Python-3.9.2 && ./configure --prefix=/usr/local/python3.9.2 --enable-shared && make -j8 && make install
    
  5. Copy libpython3.9.so.1.0 to the system path.
    1
    cp /usr/local/python3.9.2/lib/libpython3.9.so.1.0 /usr/lib
    
  6. Set the environment variables.
    1
    2
    export LD_LIBRARY_PATH=/usr/local/python3.9.2/lib:$LD_LIBRARY_PATH
    export PATH=/usr/local/python3.9.2/bin:$PATH
    

If the error message "No module named 'dnf'" is displayed when you run the yum command after Python 3.9.2 is installed using the source code, delete the Python path from LD_LIBRARY_PATH and use the Python path of the system.