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:
cd ../pythonFrom the project root, use this instead:
cd pythonStay 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_envvirtual 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
venvby default. On Ubuntu/Debian, add it withsudo apt install python3-venv.
Start the installer:
python3 install.pyWhen the script completes, activate the virtual environment:
source vector_demo_env/bin/activateUpdate your .env file
Edit python/.env and fill in the values from your deployment:
# 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 chainBLOCKCHAIN_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 selectionEMBEDDING_MODEL=sentence-transformers/all-mpnet-base-v2- Set
PRIV_KEYto the private key you created earlier withchr keygen - Set
EMBEDDING_MODELto the same model you chose in the embedding model lesson (Lesson 1) BOX_OFFICE_THRESHOLDdetermines 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.
- A higher value keeps only the highest-grossing movies.
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.