Skip to content

Environment

This content is for Python. Switch to the latest version for up-to-date documentation.

Virtual environments (venv) isolate your project’s dependencies from the system Python so different projects don’t conflict.

Create and activate a venv:

Terminal window
# Create a venv in the .venv folder (convention)
python -m venv .venv
# On Windows Command Prompt
.venv\Scripts\Activate.bat
# On Windows PowerShell
.venv\Scripts\Activate.ps1
# Activate (macOS/Linux)
source .venv/bin/activate
# Verify
python -V

Deactivate with deactivate.

Terminal window
# Activate (macOS/Linux)
source .venv/bin/deactivate
# On Windows PowerShell
# .venv\Scripts\Deactivate.ps1

Install, upgrade, uninstall:

Terminal window
pip install numpy
pip install --upgrade pip
pip uninstall numpy

Freeze your current environment to a requirements file:

Terminal window
pip freeze > requirements.txt

Install from a requirements.txt:

Terminal window
pip install -r requirements.txt

Use the -m flag to run installed modules and ensure the correct interpreter is used:

Terminal window
python -m http.server 8000
Terminal window
# 1) Create project and venv
mkdir myapp && cd myapp
python -m venv .venv
source .venv/bin/activate
# 2) Install deps
pip install numpy
# 3) Save exact versions
pip freeze > requirements.txt
# 4) Recreate env later
venv .venv
source .venv/bin/activate
pip install -r requirements.txt

JupyterLab is the next-generation web interface for Jupyter notebooks, consoles, and file management.

Terminal window
pip install jupyterlab
Terminal window
# Start JupyterLab (opens in your browser)
jupyter lab
  • If the browser does not open, copy the token URL printed in the terminal to your browser.
  • Stop the server with Ctrl+C in the terminal.

Free, cloud-based platform that allows users to write and execute Python code in a Jupyter Notebook environment.

Built with passion by Ngineer Lab