Skip to content

gh-136880: Add warning about PYTHONPATH#151098

Open
glennglazer wants to merge 6 commits into
python:mainfrom
glennglazer:Doc-Venv-136880
Open

gh-136880: Add warning about PYTHONPATH#151098
glennglazer wants to merge 6 commits into
python:mainfrom
glennglazer:Doc-Venv-136880

Conversation

@glennglazer

@glennglazer glennglazer commented Jun 8, 2026

Copy link
Copy Markdown

Warn people that PYTHONPATH is inherited in the venv, this can produce unexpected results such as the wrong library version (if system is different than venv requirements) or even completely incompatible references.

See conversation here:

python#136880

for the request for this documentation update.
@python-cla-bot

python-cla-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

replace with simple highlighting
@read-the-docs-community

read-the-docs-community Bot commented Jun 8, 2026

Copy link
Copy Markdown

@vsajip vsajip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you get that PYTHONHOME is managed by the activated venv?

$ python3.14 -m venv /tmp/foo
$ echo $PYTHONHOME

$ source /tmp/foo/bin/activate
$ echo $PYTHONHOME

I don't think the first sentence is correct. You could validly say "Note that activating a virtual environment does not alter the PYTHONPATH ..."

@glennglazer

Copy link
Copy Markdown
Author

Where do you get that PYTHONHOME is managed by the activated venv?

$ python3.14 -m venv /tmp/foo
$ echo $PYTHONHOME

$ source /tmp/foo/bin/activate
$ echo $PYTHONHOME

I don't think the first sentence is correct. You could validly say "Note that activating a virtual environment does not alter the PYTHONPATH ..."

That was the guidance I received in the issue, see #136880 (comment) .

I'm perfectly fine with your suggested change.

Clarified that the activated virtual environment does not alter the PYTHONPATH variable.
Comment thread Doc/tutorial/venv.rst
Reformat note about PYTHONPATH and virtual environments for clarity.
remove trailing whitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants