uv icon indicating copy to clipboard operation
uv copied to clipboard

uv doesn't detect pyenv-virtualenv shim environments

Open jarshwah opened this issue 1 year ago • 3 comments

uv doesn't seem able to detect the virtual-environment created by pyenv-virtualenv.

uv version and repro:

$ pyenv virtualenv 3.10.2 myenv
$ pyenv local myenv
$ which python
/Users/josh/.pyenv/shims/python

$ uv pip install pip==22.0.3
error: Failed to locate a virtualenv or Conda environment (checked: `VIRTUAL_ENV`, `CONDA_PREFIX`, and `.venv`). Run `uv venv` to create a virtualenv.

$ uv --version
uv 0.1.13 (9ce5170e6 2024-02-29)

$ python --version
Python 3.10.12

But it does detect the virtualenv when activating the shell:

$ pyenv activate kraken-uv
$ uv pip install pip==22.0.3
Resolved 1 package in 312ms
Downloaded 1 package in 168ms
Installed 1 package in 8ms
 - pip==23.0.1
 + pip==22.0.3

jarshwah avatar Mar 01 '24 11:03 jarshwah

Workaround for those that are interested, using direnv:

if [ -f ".python-version" ] ; then
    envname=$(cat .python-version)
    VIRTUAL_ENV="$(pyenv root)/versions/$envname"
    export VIRTUAL_ENV
fi

jarshwah avatar Mar 18 '24 00:03 jarshwah

How about VIRTUAL_ENV="$(pyenv root)/versions/$(pyenv version-name)"?

NeilGirdhar avatar Apr 11 '24 14:04 NeilGirdhar