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

uv use wrong interpreter when uv venv, and activated wrong environment when activate venv #2649

Closed
kevindaffaarr opened this issue Mar 25, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@kevindaffaarr
Copy link

kevindaffaarr commented Mar 25, 2024

Run On
uv version: 0.1.24
OS: Windows 11

Problem Reproducing

I have multiple python version in my PC with aliases python, python310, and python311. I already install uv in python311 by

python311 -m pip install uv

And then I check the other python

python -m pip freeze // there is no uv installed

python310 -m pip freeze // there is no uv installed

which is expected.

Then I trigger command for creating a virtual environment:

python311 -m v venv

First Problem

The first problem is, uv use python alias (which is python 3.10.8) as interpreter.

Second Problem

After I activate the venv and pip freeze

source ./.venv/Scripts/Activate
pip freeze

It resulted the activated python interpreter of my other folder with installed packages, meanwhile my current Lib folder is empty.

Below is the full terminal interactions
kevin@DESKTOP-G3K95A5 MINGW64 /d/Quantist/testing
$ python311 -m pip install uv
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: uv in c:\users\kevin\appdata\roaming\python\python311\site-packages (0.1.24)

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: python311.exe -m pip install --upgrade pip


kevin@DESKTOP-G3K95A5 MINGW64 /d/Quantist/testing
$ python311 -m pip freeze
// truncated because too long
pexpect==4.9.0
pip-tools==7.4.0
pkginfo==1.9.6
platformdirs==3.11.0
poetry==1.7.1
poetry-core==1.8.1
poetry-plugin-export==1.6.0
ptyprocess==0.7.0
pyproject_hooks==1.0.0
pywin32-ctypes==0.2.2
rapidfuzz==3.6.1
requests==2.31.0
requests-toolbelt==1.0.0
shellingham==1.5.4
tomlkit==0.12.3
trove-classifiers==2024.1.8
urllib3==2.1.0
uv==0.1.24
virtualenv==20.25.0
zipp==3.17.0
// truncated because too long


kevin@DESKTOP-G3K95A5 MINGW64 /d/Quantist/testing
$ python311 -m uv venv
Using Python 3.10.8 interpreter at: C:\Program Files\Python310\python.exe
Creating virtualenv at: .venv
Activate with: source .venv\bin\activate


kevin@DESKTOP-G3K95A5 MINGW64 /d/Quantist/testing
$ source ./.venv/Scripts/activate


(testing)
kevin@DESKTOP-G3K95A5 MINGW64 /d/Quantist/testing
$ pip freeze
// truncated because too long
pywin32==306
pywin32-ctypes==0.2.2
pyzmq==25.1.1
rapidfuzz==3.6.1
requests==2.31.0
requests-toolbelt==1.0.0
rsa==4.9
shellingham==1.5.4
six==1.16.0
soupsieve==2.5
SQLAlchemy==2.0.27
sqlalchemy-bigquery @ git+https://github.com/googleapis/python-bigquery-sqlalchemy.git@0c4cf07dce7e70cd04b196ca72193a65f95e3567
stack-data==0.6.2
tomli==2.0.1
tomlkit==0.12.3
tornado==6.3.3
traitlets==5.10.0
trove-classifiers==2024.1.8
typing_extensions==4.7.1
tzdata==2023.3
urllib3==2.0.5
virtualenv==20.24.5
wcwidth==0.2.6
zipp==3.17.0
// truncated because too long


(testing)
kevin@DESKTOP-G3K95A5 MINGW64 /d/Quantist/testing
$ uv pip freeze
bash: uv: command not found

(testing)
kevin@DESKTOP-G3K95A5 MINGW64 /d/Quantist/testing
$ uv
bash: uv: command not found

(testing)
kevin@DESKTOP-G3K95A5 MINGW64 /d/Quantist/testing
$
@zanieb
Copy link
Member

zanieb commented Mar 25, 2024

This sounds like it would be resolved by #2338 and looks like a duplicate of #2222

See also #2386

@zanieb zanieb added the duplicate This issue or pull request already exists label Mar 25, 2024
@charliermarsh
Copy link
Member

Closing in favor of those related issues. Thanks!

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2024
zanieb added a commit that referenced this issue May 22, 2024
…-m uv` (#3736)

Closes #2222
Closes #2058
Replaces #2338
See also #2649

We use an environment variable (`UV_INTERNAL__PARENT_INTERPRETER`) to
track the invoking interpreter when `python -m uv` is used. The parent
interpreter is preferred over all other sources (though it will be
skipped if it does not meet a `--python` request or if `--system` is
used and it belongs to a virtual environment). We warn if `--system` is
not provided and this interpreter would mutate system packages, but
allow it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants