# Finalize your Python environment · Semantic search on Chromia using Vector DB · Learn Chromia

> This lesson walks you through setting up your Python environment with the bundled installation script. The script creates a virtual environment, picks the…

Source: https://chromia.com/learn/vector-db-movie-demo/setup/finalize-python-env/

Semantic search on Chromia using Vector DBLesson 6 of 15

1. [01Searching movies semantically on Chromia](https://chromia.com/learn/vector-db-movie-demo/introduction/)

Module 1: Project setup

1. [02Overview](https://chromia.com/learn/vector-db-movie-demo/setup/)
2. [03Choose an embedding model](https://chromia.com/learn/vector-db-movie-demo/setup/embedding-model/)
3. [04Configure your Rell module](https://chromia.com/learn/vector-db-movie-demo/setup/configure.rell/)
4. [05Deploy your Rell module](https://chromia.com/learn/vector-db-movie-demo/setup/deploy-rell-module/)
5. [06Finalize your Python environment](https://chromia.com/learn/vector-db-movie-demo/setup/finalize-python-env/)

Module 2: Running the data pipeline

1. [07Overview](https://chromia.com/learn/vector-db-movie-demo/data-pipeline/)
2. [08Preprocess movie data](https://chromia.com/learn/vector-db-movie-demo/data-pipeline/preprocess/)
3. [09Generate sentence embeddings](https://chromia.com/learn/vector-db-movie-demo/data-pipeline/generate-embeddings/)
4. [10Store vectors on the blockchain](https://chromia.com/learn/vector-db-movie-demo/data-pipeline/upload-vectors/)

1. [11Search the vector database](https://chromia.com/learn/vector-db-movie-demo/search/)

Module 4: A deep dive into the code

1. [12Overview](https://chromia.com/learn/vector-db-movie-demo/code-deep-dive/)
2. [13Link your data to the Vector DB with Rell](https://chromia.com/learn/vector-db-movie-demo/code-deep-dive/rell-interface/)
3. [14Work with Chromia through the Python client](https://chromia.com/learn/vector-db-movie-demo/code-deep-dive/python-client/)

1. [15Use cases and extensions](https://chromia.com/learn/vector-db-movie-demo/use-cases/)

[Learn](https://chromia.com/learn/)[Semantic search on Chromia using Vector DB](https://chromia.com/learn/vector-db-movie-demo/)

06 / 15Module 1: Project setupAdvanced

# Finalize your Python environment

This lesson walks you through setting up your Python environment with the bundled installation script. The script creates a virtual environment, picks the right PyTorch build for your hardware (GPU or CPU), and installs every dependency the project needs.

## Navigate to the Python folder

From the `rell/` folder, go up one level and enter the Python folder:

bash

```nolines
cd ../python
```

From the project root, use this instead:

bash

```nolines
cd python
```

Stay in the `python/` folder for the remaining steps.

## Run the install script

The script takes care of the full setup:

* Sets up a `vector_demo_env` virtual environment, unless one already exists
* Checks your platform and whether a GPU is available
* Installs PyTorch with the matching backend: CUDA, MPS, or CPU-only
* Installs the project dependencies from `requirements.txt`

> Note: your system might not include `venv` by default. On Ubuntu/Debian, add it with `sudo apt install python3-venv`.

Start the installer:

bash

```nolines
python3 install.py
```

When the script completes, activate the virtual environment:

bash

```nolines
source vector_demo_env/bin/activate
```

## Update your `.env` file

Edit `python/.env` and fill in the values from your deployment:

env

```
# A list of Postchain node URLs (must be valid JSON)
NODE_URL_POOL='["https://node0.testnet.chromia.com:7740", "https://node1.testnet.chromia.com:7740", "https://node2.testnet.chromia.com:7740", "https://node3.testnet.chromia.com:7740"]'

# The blockchain RID of your deployed chain
BLOCKCHAIN_RID=<your-blockchain-rid>

# Your private key (for signing transactions)
PRIV_KEY=<your-private-key>

# 💰 Box office threshold for vectorization (movies below this are skipped)
BOX_OFFICE_THRESHOLD=100_000_000

# 🧠 Embedding model selection
EMBEDDING_MODEL=sentence-transformers/all-mpnet-base-v2
```

* Set `PRIV_KEY` to the private key you created earlier with `chr keygen`
* Set `EMBEDDING_MODEL` to the same model you chose in [the embedding model lesson (Lesson 1)](https://chromia.com/learn/vector-db-movie-demo/setup/embedding-model/)
* `BOX_OFFICE_THRESHOLD` determines how many movies get embedded and stored on-chain:
  + A **higher** value keeps only the highest-grossing movies.  
    Fewer vectors mean faster embedding (converting text to vectors).
  + A **lower** value keeps more titles.  
    More vectors mean slower embedding, particularly on CPU.

On a CPU-only machine, pick a higher threshold such as `500_000_000` to keep things fast.  
With a GPU, you can go lower, or use `0` to embed the entire dataset, which can take roughly 15–20 minutes.  
The default of `100_000_000` gives quick results on a GPU without dropping too many titles.

## What’s next?

Your Python environment is installed and `.env` is configured, so you can move on to working with the data.

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**Deploy your Rell module**](https://chromia.com/learn/vector-db-movie-demo/setup/deploy-rell-module/)[Next →**Module 2: Running the data pipeline**](https://chromia.com/learn/vector-db-movie-demo/data-pipeline/)

On this page

* [Navigate to the Python folder](#navigate-to-the-python-folder)
* [Run the install script](#run-the-install-script)
* [Update your .env file](#update-your-env-file)
* [What’s next?](#whats-next)
