Installing relationalai Locally#

This guide shows you how to install the relationalai package into a local Python environment.

Install Python and the relationalai package#

Follow the steps for your operating system to install Python and the relationalai package.

NOTE

The relationalai Python package requires Python 3.9, 3.10, or 3.11. If you have an existing compatible Python installation, skip to the last step below.

  1. Navigate to the Python 3.11 download page, scroll down to the Files section, and download the macOS 64-bit universal2 installer.

  2. Open the installer and follow the prompts to install Python 3.11. Use the default installation options. When the installation is complete, double click the Install Certificates command in the Finder window.

  3. Open a terminal and verify that Python 3.11 is installed by running:

    #python3.11 --version
    

    The output should be similar to Python 3.11.9.

  4. Create a new project directory and virtual environment and use pip to install the relationalai package:

    #mkdir rai-getting-started && cd rai-getting-started
    
    # Replace `python3.11` with `python3.9` or `python3.10`
    # if you're using a different version.
    python3.11 -m venv .venv  # Create a virtual environment.
    source .venv/bin/activate  # Activate the virtual environment.
    
    python -m pip install relationalai
    

    Activating your virtual environment adds .venv/bin to your PATH, so you can use its Python executable as python.

    TIP

    Activate your virtual environment each time you open a new terminal to use the correct Python version and access the relationalai package.

Configure your project#

Run rai init to connect to your Snowflake account and configure a new model:

#rai init

Follow the interactive prompts to enter your Snowflake credentials and choose the:

IMPORTANT

rai init saves your model’s configuration to a file named raiconfig.toml in the current directory. This file contains sensitive information, so be sure to exclude it from version control!

Test your installation#

To verify that your model is configured correctly, open a Python editor or notebook and run:

#import relationalai as rai

# Create a model named "power_transmission_network".
model = rai.Model("power_transmission_network")

# Send a test query.
with model.query() as select:
    response = select(1 + 1)

# The results are stored as a pandas DataFrame in the `results` attribute.
print(response.results)
# Output:
#    v
# 0  2

Next steps#

To begin exploring RelationalAI’s capabilities, check out the Getting Started guide or the Example Notebooks.