-
Notifications
You must be signed in to change notification settings - Fork 1
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
Errors when using Pythons managed/installed by UV #6
Comments
Even when the Looking into the implementation of def _running_under_venv() -> bool:
"""Checks if sys.base_prefix and sys.prefix match.
This handles PEP 405 compliant virtual environments.
"""
return sys.prefix != getattr(sys, "base_prefix", sys.prefix)
def _running_under_legacy_virtualenv() -> bool:
"""Checks if sys.real_prefix is set.
This handles virtual environments created with pypa's virtualenv.
"""
# pypa/virtualenv case
return hasattr(sys, "real_prefix")
def running_under_virtualenv() -> bool:
"""True if we're running inside a virtual environment, False otherwise."""
return _running_under_venv() or _running_under_legacy_virtualenv() The result of this function ultimately triggers the "Could not find activated virtual environment" warning. As you can see, it doesn't check There are more details about these |
My guess right now is that relying on the |
I've pushed a fix for this. However, the pipeline is not working at the moment due to #7 so we can't publish a new version. I'm leaving this open until we do that just for visibility. |
First I'll lay out the problem as I've encountered it...
UV is able to install Pythons, much like pyenv. Suppose I create a virtual environment using a UV-managed Python, and then create a second virtual environment from the first one:
In this case, the
pyvenv.cfg
of the second virtual environment has the keyexecutable
pointing to the UV-managed Python executable:As a result, the
python_executable_path()
function returns that exectuble - i.e. the base UV-managed Python/Users/austin/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/bin/python3.11
- in situations wherevenv_management
has used a UV-managed venv to create another venv.This is a problem for the case where we use that executable to try to install packages using pip, e.g.:
When we try to do this, the command reports that
ERROR: Could not find an activated virtualenv (required).
.The text was updated successfully, but these errors were encountered: