0

I am not allowed to install anaconda on my enterprise machine, so I decided to use pyenv to manage virtual environments. I am following this tutorial to get my hands on pyenv. I think that my issue is close to what represented here.

At this time I have windows powershell open as administrator. When I do:

pyenv versions

I will get:

enter image description here

And when I do:

ls $PYENV_ROOT/versions/

I will get:

enter image description here

Impossible to find path to "C:\versions", cause it does not exist.

Also when I do:

pyenv version

I will get: enter image description here

Another strange observation is that when I open another powershell (or CMD) window without administrative right and call pyenv, It does not recognize it.

enter image description here

2
  • Have you tried to set global version with pyenv global <version-number-you-want>? Commented Nov 17 at 11:03
  • I just did that. Asterix apears next to the globaly-set python version but still "ls $PYENV_ROOT/versions/" can not find the path. It seems to me that I have to manually set some path! Commented Nov 17 at 11:40

1 Answer 1

0
  1. Run in PowerShell and install pyenv-win:

    Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
    
    Invoke-WebRequest -UseBasicParsing `
      -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" `
      -OutFile "$env:TEMP\install-pyenv-win.ps1"
    
    & "$env:TEMP\install-pyenv-win.ps1"
    
    
  2. Run in PowerShell add env vars:

    [System.Environment]::SetEnvironmentVariable(
      'PYENV',
      $env:USERPROFILE + "\.pyenv\pyenv-win\",
      'User'
    )
    [System.Environment]::SetEnvironmentVariable(
      'PYENV_ROOT',
      $env:USERPROFILE + "\.pyenv\pyenv-win\",
      'User'
    )
    [System.Environment]::SetEnvironmentVariable(
      'PYENV_HOME',
      $env:USERPROFILE + "\.pyenv\pyenv-win\",
      'User'
    )
    
    [System.Environment]::SetEnvironmentVariable(
      'Path',
      $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" +
      $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" +
      [System.Environment]::GetEnvironmentVariable('Path', 'User'),
      'User'
    )
    
    
  3. Run in PowerShell:
    pyenv versions

  4. Set global PYENV:
    pyenv global 3.10.11

    pyenv rehash

    pyenv version

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.