OpenViSTAI · Agents · Blockchain · Crypto
Menu

OPENVIST LEARN · FREE LESSONS

Virtual environments and dependency choices

Keep a project’s packages separate and recognise when no package installation is needed.

Lesson 19 of 22 · About 20 minutes · Beginner · English

By the end of this lesson

Create a practice virtual environment and identify its interpreter.

Before you start

  • Python 3.12 or a compatible newer Python 3 interpreter; no external packages.
  • Complete lesson 18 in this route, or be comfortable with its examples.

Three words to know

Virtual environment
A project-specific interpreter environment and package location.
Dependency
Software your program needs in addition to its own files.
pip
Python’s package installer, invoked for a particular interpreter.

1. No extra packages for this course

Everything in this route uses the standard library. You do not need pip install to import json, csv, argparse or unittest. A virtual environment is still useful for learning how a future project can keep its installed packages separate. It is not a security sandbox for untrusted Python code.

2. Create an environment in your practice folder

Create a new practice environmentTERMINAL · Bash
python3 -m venv .venv
.venv/bin/python --version
What you should see · example output
Python 3.x.x

Use a fresh .venv name for this exercise. On Ubuntu, if venv reports that ensurepip is unavailable, use the Terminal & VPS Python setup lesson and install the distribution’s python3-venv package. On Windows use py -3 -m venv .venv, then .\.venv\Scripts\python.exe --version. The explicit path works without changing activation settings.

3. Tie packages to the intended interpreter

A future package command should use that environment’s interpreter followed by -m pip, so you know where it installs. Activation is a convenience for selecting commands, not a requirement. Do not copy .venv between different operating systems or commit it to a source repository; record dependencies and recreate the environment instead. Dependencies, versions and supply-chain review are part of a separate project decision.

YOUR TURN

A small check before you continue

Do you need to install a package named json to run lesson 16? Does a virtual environment stop a malicious script reading your files?

Show a suggested answer

No to both. json is in the standard library, and a virtual environment isolates package selection rather than operating-system permissions.

Sources and scope

Documentation and examples reviewed 2026-10-18. Provider screens, package versions and output wording can differ. Examples show expected outcomes; they are not a claim that OpenViST connected to your server or verified your setup.