Updated on 2023-08-31 GMT+08:00

Configuring the Python3 Sample Project

Scenario

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

The sample can run only on Linux nodes.

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. You can obtain the corresponding installation package from 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 following command in the CLI of the client:

    python3 setup.py install

    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. If the egg file has dependencies, you can use wildcards to install the egg file. For example:
      • dependency_python3.6 directory:

        /usr/local/bin/easy_install future*egg six*egg python*egg sasl-*linux-$(uname -p).egg thrift-*egg thrift_sasl*egg

      • dependency_python3.7 directory:

        /usr/local/bin/easy_install future*egg six*egg sasl-*linux-$(uname -p).egg thrift-*egg thrift_sasl*egg

      • dependency_python3.8 directory:

        /usr/local/bin/easy_install future*egg six*egg python*egg sasl-*linux-$(uname -p).egg thrift-*linux-$(uname -p).egg thrift_sasl*egg

      If the following information is displayed for each egg file, the installation is successful:

      Finished processing dependencies for ***     

  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.