Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

venv can't figure out that it's isolated #127025

Open
imperialwool opened this issue Nov 19, 2024 · 5 comments
Open

venv can't figure out that it's isolated #127025

imperialwool opened this issue Nov 19, 2024 · 5 comments
Labels
topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error

Comments

@imperialwool
Copy link

imperialwool commented Nov 19, 2024

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

@imperialwool imperialwool added the type-bug An unexpected behavior, bug, or error label Nov 19, 2024
@brettcannon brettcannon added the topic-venv Related to the venv module label Nov 20, 2024
@brettcannon
Copy link
Member

What's the pip command you used for doing the package installation?

@imperialwool
Copy link
Author

Something like pip install orjson, pip install Pillow...

@imperialwool
Copy link
Author

imperialwool commented Nov 20, 2024

2024-11-20 14:51:48 2024-11-20 14:52:43

Providing examples.

upd: if needed, can provide venv in archive to download and make own tests

@brettcannon
Copy link
Member

Best way to test where the problem is would be to put a file in the virtual environment's site-packages, launch Python, and then see if you can import the file. That will tell you if the virtual environment is somehow the cause.

I would also launch pip via venv/bin/python -m pip to make sure there's no weird PATH issue going on here.

But based on what your pip3 file contains, my guess it's Homebrew or pip since virtual environments don't do anything magical when it comes to installing pip and I've never seen that sort of message before. You can also try your own copy of pip to see it that changes things (e.g., download https://bootstrap.pypa.io/pip/pip.pyz and see if running that works; venv/bin/python pip.pyz install orjson).

if needed, can provide venv in archive to download and make own tests

Virtual environments are not portable, so that wouldn't be useful.

@imperialwool
Copy link
Author

I would also launch pip via venv/bin/python -m pip to make sure there's no weird PATH issue going on here.

Just tried, the same error as I shown.
Also tried to use "pip.pyz" as you suggested, also the same error.
All paths are ok as venv/bin/python pip.pyz inspect showing.

Best way to test where the problem is would be to put a file in the virtual environment's site-packages, launch Python, and then see if you can import the file. That will tell you if the virtual environment is somehow the cause.

I think I should move or duplicate this issue to pip since packages and venv working as intended.
I just did issue here since it worked ok in python3.12, but only in python3.13 it doesn't work (both are from homebrew). I thought that it can be some python error since even latest pip version and even other pips (as you suggested to try) just showing the same message.
I can also try to compile python3.13 from source, install pip and see if error is still there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants