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

Configuring the Python Sample Project

Scenario

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

  • MRS 3.1.2 and later versions support only Python3 by default.
  • The sample can run only on Linux nodes.

Procedure

  1. Python of 2.6.6 or a higher version has been installed on a client. The Python version cannot be higher than 2.7.13.

    The Python version can be viewed by running the python command on the command-line interface (CLI) of the client. The following information indicates that the Python version is 2.6.6.
    Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)  
    [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 
    Type "help", "copyright", "credits" or "license" for more information.     

  2. Setuptools of 5.0 or a higher version has been installed on a client. The setuptools version cannot be higher than 36.8.0. 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:

    python setup.py install

    The following information indicates that setuptools 5.7 is installed successfully.

    Finished processing dependencies for setuptools==5.7     

  3. Install Python on the client.

    1. Obtain the sample project folder python-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 python-examples folder.
    3. Run the following command in the CLI.

      python setup.py install

      The following information indicates that Python is installed successfully.

      Finished processing dependencies for pyhs2==0.5.0     

  4. After the installation is successful, the following files are generated. python-examples/pyCLI_nosec.py is the Python client example codes. python-examples/pyhs2/haconnection.py is the Python client API. Run hive_python_client scripts to execute the SQL functions, for example, sh hive_python_client 'show tables'. This function applies to only simple SQL statements and depends on the ZooKeeper client.