-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Check whether the interpreter currently set in PATH
is associated with a virtual environment
#4009
Comments
Thanks @dpoznik! |
Thanks for the issue! We should definitely support this without requiring a Do you know why pyenv environments do not have |
Sounds great; thanks!
Yes, pyenv-virtualenv uses
In case relevant, I have the following in my
That configures Thanks for your help! |
Hm I'm confused that the virtual environment isn't PEP 405 compliant if it has |
Interesting. I'm not all that familiar with PEP 405 or with how pyenv-virtualenv sets up environments. It's definitely possible I'm missing something, but I don't think #4018 will address this issue, as $ pyenv version
uv (set by PYENV_VERSION environment variable)
$ env | grep VIRTUAL_ENV
$ |
Oh sorry I think I might have misunderstood the original issue! I'll start from the top so we can make sure we're on the same page. PEP 405 stipulates
Thus, we say a PEP 405 compliant virtual environment must have inequal uv/crates/uv-interpreter/src/interpreter.rs Lines 156 to 162 in 365ca63
(and in As I understand re-reading your comments now, you do have a compliant virtual environment in the current interpreter, e.g. We only detect virtual environments in three ways:
We don't currently support checking if the current interpreter on the |
Cool, thanks for all the information. We are definitely on the same page now.
Exactly:
Got it. That explains it, as the pyenv-virtualenv has none of these properties. Thanks for this information!
Exactly.
That would be great; thanks! Now that I have a better sense of what's going on, I'll go ahead and rename the Issue. |
PATH
is a virtual environment
PATH
is a virtual environmentPATH
is a virtual environment
## Summary This meta-PR includes some suggestions for the docs on installing into arbitrary Python environments. It targets the branch in #4031 and is a response to #3951 (comment). Specifically, it: - Moves mention of `--python=$(which python)` out of the `--system` paragraph, as the two are no longer equivalent - Adds additional notes on how, currently, to install for the current interpreter. This section should be updated once #4009 is implemented :)
PATH
is a virtual environmentPATH
is associated with a virtual environment
I noticed that the problem reported in this issue has been resolved. Thanks! Executing the same sequence of commands as is found in the description results in an expected/successful outcome. So I will go ahead and close the issue. $ venv_name=uv
$ pyenv uninstall --force ${venv_name}
$ pyenv virtualenv ${venv_name}
$ pyenv shell ${venv_name}
$ pyv
uv (set by PYENV_VERSION environment variable)
$ pip install uv
[details omitted]
$ uv --version
uv 0.5.0 (8d665267c 2024-11-07)
$ pyenv version
uv (set by PYENV_VERSION environment variable)
$ python -c 'import sys; print(f"{(sys.prefix==sys.base_prefix)=}")'
(sys.prefix==sys.base_prefix)=False
$ uv pip install --upgrade pip --verbose
DEBUG uv 0.5.0 (8d665267c 2024-11-07)
DEBUG Searching for default Python interpreter in virtual environments
DEBUG Found `cpython-3.12.7-macos-aarch64-none` at `/Users/dpoznik/.pyenv/versions/uv/bin/python` (search path)
Using Python 3.12.7 environment at .pyenv/versions/uv
[details omitted]
A bisection indicates that version [m|~]: uv pip install -U --python=$(which python) uv==0.2.13
Resolved 1 package in 577ms
Prepared 1 package in 10.23s
Uninstalled 1 package in 13ms
Installed 1 package in 7ms
- uv==0.2.15
+ uv==0.2.13
[m|~]: uv pip install --upgrade pip
error: No Python interpreters found in virtual environments
[m|~]: uv pip install -U --python=$(which python) uv==0.2.14
Resolved 1 package in 3.69s
Downloaded 1 package in 9.28s
Uninstalled 1 package in 14ms
Installed 1 package in 7ms
- uv==0.2.13
+ uv==0.2.14
[m|~]: uv pip install --upgrade pip
Resolved 1 package in 189ms
Audited 1 package in 0.59ms But I don't see anything in the release notes to this effect, so maybe the improvement was incidental? Just figured I'd mention in case doing so were to lessen the chance of a regression. |
This issue is forked from #3951.
When I attempt to use uv in a pyenv-virtualenv, I receive an error message indicating that there are no Python interpreters found in virtual environments. Since
sys.prefix!=sys.base_prefix
within a pyenv-virtualenv, it would be nice to be able to use uv therein, without having to invoke with--python=$(which python)
.The text was updated successfully, but these errors were encountered: