ℂ𝕠𝕟𝕥𝕚𝕟𝕦𝕦𝕞

Virtual Environment Directories

Last update: 2025-06-01

Tags: code python

The main difference is the virtual environment directory name and visibility. Both approaches work identically, they create isolated Python environments with their own packages and dependencies. The activation commands differ accordingly:

python3 -m venv .venv creates a hidden directory named .venv (the leading dot makes it hidden on Unix systems like macOS). When you run ls in your project directory, you won’t see it unless you use ls -a to show hidden files.

python3 -m venv venv creates a visible directory named venv that will show up in normal directory listings.

Many developers prefer .venv because:

Example 1

python3 -m venv .venv
source .venv/bin/activate
pip install pyyaml

To exit from a Python virtual environment, simply type deactivate

Example 2

# Create a virtual environment
python3 -m venv venv
source venv/bin/activate

# Install beautifulsoup4
pip install beautifulsoup4

# Run the script
python search_generator.py ./pages

# Deactivate when done
deactivate