Python Environment

Prerequisites

Install software listed in Table 1 to prepare the environment.

Table 1 Required software

Name

Version

Description

Python

3.7.5

For details about installation methods and restrictions on Python dependency versions, see CANN Software Installation Guide.

Python3.8.0 ~ Python3.8.10

3.9.2

Python3.10

Python dependencies

-

NumPy

≥ 1.18.2

An open-source numerical computing extension of Python

Run the pip3 install numpy command to install NumPy.

Pillow

7.2.0

A Python Imaging Library (PIL).

Run the pip3 install Pillow command to install Pillow.

This section uses example commands. You can use python and pip names (Python 3.7.5 is used as an example) in your own case and keep them consistent with those configured in soft links on users' devices.

Configuration Description of the Atlas 500 AI Edge Station

  • The pip is not installed on the preinstalled EulerOS on the Atlas 500 AI edge station. You need to perform the following steps for configuration.
  • For details about application scenarios of a container, see "Creating and Starting a Container Image" in Atlas 500 AI Edge Station User Guide. You need to install Python 3.7.5 in the container and perform the following steps for configuration.
  1. Obtain and upload the pip installation package from the pip official website. The following uses pip-20.2.3.tar.gz as an example.
  2. Go to the directory where the compressed package is stored and decompress the package.
    tar -zvxf pip-20.2.3.tar.gz
  3. Install the pip installation package.
    Run the following commands in sequence to go to the pip directory and compile and install pip:
    cd pip-20.2.3
    python3 setup.py build
    python3 setup.py install

    After the installation is complete, run the following command to check the pip version:

    pip -V

    If the following information is displayed, the installation is successful.

    pip 20.2.3 from /usr/local/lib/python3.7/site-packages/pip-20.2.3-py3.7.egg/pip (python 3.7)
  4. Run the following commands to install the NumPy and Pillow dependencies. Pay attention to the version restrictions. For details, see Table 1.
    pip install numpy
    pip install pillow

Pillow Installation in CentOS 7 AArch64

In CentOS 7 AArch64, after pip3.7 install Pillow is run to install Pillow, an error is reported when the from PIL import Image command is run.

ImportError: /usr/local/python3.7.5/lib/python3.7/site-packages/PIL/_imaging.cpython-37m-aarch64-linux-gnu.so: ELF load command alignment not page-aligned

In this case, you need to use the source code to install Pillow. If Pillow has been installed using pip, run the pip3.7 uninstall Pillow command to uninstall it.

  1. Obtain the Pillow source package from https://pypi.org/project/Pillow/#files. The following uses Pillow-7.2.0.tar.gz as an example.
  2. Check whether the following Pillow dependencies are installed. If not, install them.
    sudo yum install python-devel
    sudo yum install zlib-devel
    sudo yum install libjpeg-turbo-devel
  3. Decompress, compile, and install the Pillow source package.
    tar -xvf Pillow-7.2.0.tar.gz
    cd Pillow-7.2.0/
    python3.7 setup.py build
    python3.7 setup.py install