python / python/cpython

venv can't figure out that it's isolated

Open
#127,025 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-venv type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

I installed python3.13 on my Macbook Pro M1 using Homebrew.

I create venv, activate it and trying to install package. But I'm getting this error:
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

I figured out that I can force pip to think that it's isolated. I just added following line in venv/bin/pip3:

#...
if __name__ == '__main__':
    sys.argv.append("--isolated") # i added this line

It worked.

I don't know exactly where is problem: in pip or in venv. But in latest pip version there is the same error, so maybe it's not pip, idk. Or maybe I did something wrong, or maybe homebrew package is broken, idk.

As I remember, in python3.12 that I also installed using Homebrew there was no such error, everything worked out of box perfectly.

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported macOS Homebrew Python 3.13 setup with a virtual environment and a package installation, then inspect the generated venv/bin/pip3 entry point and the interaction between --user and --isolated. Determine whether the behavior belongs to venv or pip; done means the responsible component is identified and the regression or expected behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.