pyenv-win / pyenv-win-venv

A CLI to manage virtual envs with pyenv-win
Apache License 2.0
78 stars 8 forks source link

python installation from pyenv not detected when creating venv #1

Closed cderv closed 1 year ago

cderv commented 1 year ago

Hi,

I am trying to use this project with pyenv-win, but creating the venv does not work as expected

$ pyenv versions
* 3.9.13 (set by C:\Users\chris\scoop\apps\pyenv\current\pyenv-win\version)
$ pyenv-venv install 3.9.13 venv39
Python v3.9.13 is not installed. Install using "pyenv install 3.9.13 "
$ pyenv-venv list python
Python Versions installed:
* 3.9.13 (set by C:\Users\chris\scoop\apps\pyenv\current\pyenv-win\version)

I am using pyenv installed through scoop

arzkar commented 1 year ago

Can you please send me the output of the following commands when run in PowerShell.

echo $env:PYENV_HOME
ls $env:PYENV_HOME\versions

The issue probably has to do with the way Scoop has installed pyenv-win. I dont use Scoop so didnt encounter this issue before. Is Scoop officially supported? I dont see it in pyenv-win's README

cderv commented 1 year ago

Is Scoop officially supported? I dont see it in pyenv-win's README

I don't see it either so I asked: https://github.com/pyenv-win/pyenv-win/issues/435

Scoop is quite used on windows for package management, it is good to have pyenv in it. However, it may not be set up correctly (yet) and I am happy to help fix it.

it seems for example I don't have PYENV_HOME set. I have PYENV only.

> Get-ChildItem -Path Env: | Where-Object -FilterScript {$_.Name -contains "PYENV"}

Name                           Value
----                           -----
PYENV                          C:\Users\chris\scoop\apps\pyenv\current\pyenv-win

So probably Scoop should add the other environment defined here at installation (https://github.com/pyenv-win/pyenv-win#add-system-settings) as you are relying on them, right ? It just seems 3 times the same path in 3 different env var 🤔

arzkar commented 1 year ago

So probably Scoop should add the other environment defined here at installation (https://github.com/pyenv-win/pyenv-win#add-system-settings) as you are relying on them, right ?

Yes. It is checking if the given python version exists by looking at $PYENV_HOME\versions so it needs that environment variable. Better to add all the environment variables mentioned in https://github.com/pyenv-win/pyenv-win#add-system-settings

It just seems 3 times the same path in 3 different env var

True. No idea why it is that way.

Anyway, let me know if the issue is fixed after adding all the required environment variables.

arzkar commented 1 year ago

Found the reason for setting multiple env vars for the same path. https://github.com/pyenv-win/pyenv-win/pull/313

cderv commented 1 year ago

Yes. It is checking if the given python version exists by looking at $PYENV_HOME\versions so it needs that environment variable.

Ok great. I'll see about that. I was suprised that the python versions was still found by pyenv-win-venv

 pyenv-venv list python
Python Versions installed:
* 3.9.13 (set by C:\Users\chris\scoop\apps\pyenv\current\pyenv-win\version)

There is two mechanisms I guess.

arzkar commented 1 year ago

I was suprised that the python versions was still found by pyenv-win-venv

It's able to find the python versions because it is just runningpyenv versions whenever pyenv-venv list python is run.

cderv commented 1 year ago

Thanks a lot for the help. I'll close this, and fix in Scoop

cderv commented 1 year ago

FWIW here is the PR to change scoop installer to have expected env var: https://github.com/ScoopInstaller/Main/pull/3950

arzkar commented 1 year ago

Great. That would be very helpful for future Scoop users. 👍

GitMurf commented 4 months ago

fyi choco install has the same problem! it only sets the $PYENV env variable and not root or home.