Skip to content

gh-136880: Add warning about PYTHONPATH#151098

Merged
vsajip merged 6 commits into
python:mainfrom
glennglazer:Doc-Venv-136880
Jun 11, 2026
Merged

gh-136880: Add warning about PYTHONPATH#151098
vsajip merged 6 commits into
python:mainfrom
glennglazer:Doc-Venv-136880

Conversation

@glennglazer

@glennglazer glennglazer commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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
Contributor 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
@vsajip vsajip merged commit 84630e2 into python:main Jun 11, 2026
30 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jun 11, 2026
@vsajip vsajip added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 11, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @glennglazer for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @glennglazer for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Thanks @glennglazer for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151298 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 11, 2026
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151299 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 11, 2026
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151300 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 11, 2026
vsajip pushed a commit that referenced this pull request Jun 11, 2026
vsajip pushed a commit that referenced this pull request Jun 11, 2026
vsajip pushed a commit that referenced this pull request Jun 11, 2026
@glennglazer glennglazer deleted the Doc-Venv-136880 branch June 11, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants