Skip to content

Q&A · Answered

Python virtual environment not activating - solutions

asked 9 months, 1 week ago 803 views 1 answer
12

When I try to activate my virtual environment with "source venv/bin/activate", nothing happens. No error, but the prompt doesn't change.

1 Answer

One accepted
18

Accepted answer

Not confirmed since it was written, 9 months, 1 week ago

This can happen for several reasons. Here are the fixes:

Check if venv exists correctly

# List venv contents
ls -la venv/bin/
# You should see activate, python, pip files

Recreate the virtual environment

# Remove old venv
rm -rf venv
# Create new one
python3 -m venv venv
# Activate
source venv/bin/activate

Alternative activation methods

# For bash
source venv/bin/activate
# For zsh
source venv/bin/activate
# For fish shell
source venv/bin/activate.fish

Your answer

Say what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.

Shown beside your answer and never checked, so it cannot be a name someone already has here.

No account needed to answer. Sign in instead and it carries your name and earns reputation.