14.3.1.2 Oracle Graph Python Client

You can install the Python client by downloading the oracle-graph-client-24.1.0.zip file that is shipped with Oracle Graph Server and Client or from PyPI.

Alternatively, you can also install the python client in embedded mode.

14.3.1.2.1 Installing the Python Client from PyPI

You can obtain the property graph Python client from PyPI.

You can install the oracle-graph-client-24.1.0.zip package from the PyPI repository using pip.
Before installing the Python client from PyPI, ensure that your system meets the following requirements:
  • Supported operating systems: Linux, Windows, or macOS (M1 or M2 processor)
  • Supported JDK versions:
    • Oracle JDK 11 or JDK 17
    • OpenJDK JDK 11 or JDK 17
  • Python 3.8 or later
  • Ensure that you set the JAVA_HOME environment variable.
  • If you are behind a proxy, then set the https_proxy environment variable to the proxy server.

You can install and verify the Python client installation as shown:

  1. Install the client through pip.
    For example,
    pip install --user oracle-graph-client

    This installs the Python client along with all the required dependencies.

  2. Verify that your installation is successful.
    $ python3
    Python 3.8.12 (default, Apr  5 2022, 08:07:47)
    [GCC 8.5.0 20210514 (Red Hat 8.5.0-10.0.1)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import opg4py
    >>> import pypgx

    See Also:

    Python API Reference for more information on the Python APIs

14.3.1.2.2 Upgrading the Python Client

This section describes how to upgrade the Python client.

  1. Review the available Python client versions and the currently installed version.
    pip3 index versions oracle-graph-client
    
    WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
    oracle-graph-client (23.3.0)
    Available versions: 23.3.0, 23.2.0, 23.1.0
      INSTALLED: 23.1.0
      LATEST:    23.3.0
  2. Run the following command to upgrade your Python client.
    pip3 install oracle-graph-client --upgrade

14.3.1.2.3 Installing the Python Client From the Graph Server and Client Downloads

You can download the zip file for oracle-graph-client-24.1.0 from the Graph Server and Client downloads and install the Python client.

Before you install the Python client, ensure that you meet the following prerequisites.
  • System requirements:
    • Supported operating system: Linux
    • Supported JDK versions:
      • Oracle JDK 11 or JDK 17
      • OpenJDK JDK 11 or JDK 17
    • Supported Python versions: Python 3.8 or 3.9

      To verify that you are using the right version of the Python client, run the following command:

      python3 --version

      For more information on installing Python 3 on Oracle Linux, see Python for Oracle Linux.

    Note:

    If you are using any other operating system or Python version, then you can install the Python client from PyPI. See Installing the Python Client from PyPI for more information.
  • Ensure that python3-devel is installed in your system.

    sudo yum install python3-devel

Note:

See Python API Reference for more information on the Python APIs.

You can perform the following steps to install and connect using the Python client:

  1. Download the Oracle Graph Client from Oracle Software Cloud.
    For example, oracle-graph-client-24.1.0.zip.
  2. Unzip the file into a directory of your choice.

    The unzipped folder contains the oracle-graph-python-client-24.1.0.zip file for installing the Python client.

  3. Install the Python client by running the following command.
    python3 oracle-graph-python-client-24.1.0.zip --user
  4. Configure your client to trust the self-signed keystore. See Configuring a Client to Trust the Self-Signed Keystore for more information.
  5. Start the OPG4Py shell to connect to the graph server(PGX) by running the following command:
    cd <CLIENT_INSTALL_DIR>
    ./bin/opg4py --base_url https://<host>:7007

    In the preceding code:

    • <CLIENT_INSTALL_DIR>: Directory where the shell executables are located.

      The shell executables are found in <CLIENT_INSTALL_DIR>/bin after the client installation.

    • <host>: Server host

      Note:

      The graph server (PGX), listens on port 7007 by default. If needed, you can configure the graph server to listen on a different port by changing the port value in the server configuration file (server.conf). See Configuring the Graph Server (PGX) for details.

    You are prompted to enter your username and password.

    See Starting the OPG4Py Shell for more information on the different ways you can start the OPG4Py shell.

    The OPG4Py shell starts and the following command line prompt appears as shown:

    Oracle Graph Server Shell 24.1.0
    >>>

    Note:

    You can also install the python client library in Jupyter Notebook. Using the Python API, you can then connect to the graph server (PGX) to run PGQL queries and graph algorithms in a Jupyter Notebook environment. See Using the Jupyter Notebook Interface for more details.

14.3.1.2.4 Installing the Python Client in Embedded Mode

You can install and work with the Python client in embedded mode.

To install the embedded Python client:

  1. Run the following command:
     python3 /opt/oracle/graph/client/oracle-graph-python-embedded-24.1.0.zip --user
  2. Start the OPG4Py shell in embedded mode as shown:
    cd /opt/oracle/graph
    ./bin/opg4py

    Note that the shell executables are found in /opt/oracle/graph/bin after the server installation.

    The OPG4Py shell starts and the following command line prompt appears as shown:

    Oracle Graph Server Shell 24.1.0
    >>> instance
    ServerInstance(embedded: True, version: 24.1.1)
    >>>

14.3.1.2.5 Uninstalling the Python Client

This section describes how to uninstall the Python client.

To uninstall the Python client, run the following command:

pip uninstall oracle-graph-client