Updated on 2022-11-18 GMT+08:00

Configuring the Python3 Sample Project

Scenario

To run the Python3 interface example codes of the Hive component of FusionInsight MRS, perform the following operations.

Procedure

  1. Python3 of 3.6 or a higher version has been installed on a client. The Python3 version cannot be higher than 3.8.

    The Python version can be viewed by running the python3 command on the command-line interface (CLI) of the client. The following information indicates that the Python version is 3.8.2.
    Python 3.8.2 (default, Jun 23 2020, 10:26:03)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
    Type "help", "copyright", "credits" or "license" for more information.     

  2. Setuptools of 47.3.1 version has been installed on a client.

    To obtain the software, visit the official website.

    https://pypi.org/project/setuptools/#files

    Copy the downloaded setuptools package to the client, decompress the package, go to the decompressed directory, and run the python3 setup.py install command in the CLI of the client.

    The following information indicates that setuptools 47.3.1 is installed successfully.

    Finished processing dependencies for setuptools==47.3.1

    If the system displays a message indicating that the installation of setuptools of 47.3.1 fails, check whether the environment is faulty or whether the problem is caused by Python.

  3. Install Python on the client.

    1. Obtain the sample project folder python3-examples in the src\hive-examples directory where the sample code is decompressed. For details, see Obtaining Sample Projects from Huawei Mirrors.
    2. Go to the python3-examples folder.
    3. Go to the dependency_python3.6, dependency_python3.7, or dependency_python3.8 folder based on the Python3 version.
    4. Run the whereis easy_install command to find the path of the easy_install program. If there are multiple paths, run the easy_install --version command to select the easy_install path corresponding to the setuptools version, for example, /usr/local/bin/easy_install.
    5. Run the easy_install command to install the egg files in the dependency_python3.x folder in sequence. Example:

      /usr/local/bin/easy_install future-0.18.2-py3.8.egg

      The following information indicates that egg is installed successfully.

      Finished processing dependencies for future==0.18.2     

      If egg files of both aarch64 and x86_64 versions exist in the dependency_python3.x folder, you need to select one of the versions based on the operating system and run the uname -p command to check the current operating system architecture.

  4. After the installation is successful, the following files are generated. python3-examples/pyCLI_sec.py is the Python client example codes. python3-examples/pyhive/hive.py is the Python client API.