Skip to content

uv doesn't detect pyenv-virtualenv shim environments #2109

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

Closed
jarshwah opened this issue Mar 1, 2024 · 8 comments
Closed

uv doesn't detect pyenv-virtualenv shim environments #2109

jarshwah opened this issue Mar 1, 2024 · 8 comments

Comments

@jarshwah
Copy link

jarshwah commented Mar 1, 2024

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 jarshwah changed the title uv doesn't detect pyenv-virtualenv environments uv doesn't detect pyenv-virtualenv shim environments Mar 1, 2024
@jarshwah
Copy link
Author

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

@NeilGirdhar
Copy link

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

@zanieb
Copy link
Member

zanieb commented Jul 1, 2024

Would be closed by #4032

@zanieb
Copy link
Member

zanieb commented Feb 4, 2025

per #4009 (comment) I think this was fixed, though it may have just regressed in #11214

@dpoznik
Copy link
Contributor

dpoznik commented Feb 5, 2025

per #4009 (comment) I think this was fixed, though it may have just regressed in #11214

Confirmed. #4009 was fixed but regressed in uv 0.5.27.

@dpoznik
Copy link
Contributor

dpoznik commented Feb 5, 2025

Confirmed. #4009 was fixed but regressed in uv 0.5.27.

I see that this works again in 0.5.28. Thanks again for the quick fix!

@zanieb
Copy link
Member

zanieb commented Feb 5, 2025

Yep no problem! Thanks for following up.

@fjarri
Copy link

fjarri commented Feb 11, 2025

In 0.5.30 the sequence of actions from the top post works fine, and you can see that the venv was picked up:

> uv pip list
Using Python 3.10.10 environment at: <...>.pyenv/versions/myenv
Package    Version
---------- -------
pip        22.0.3
setuptools 65.5.0

But then running uv venv results in

  × No interpreter found for executable name `myenv` in managed installations or search path

Is it the same issue reoccurring, or should I make a new one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants