Search code examples
pythonwindowspowershellpyenv

when installing python 3.8.1 using pyenv-win getting the following output to terminal "error installing doc component MSI"


when installing python using pyenv getting installing "doc" component MSI error. I know it's not the python version causing this as I have tried multiple python versions however, still getting errors do with MSI. The python version is compatible with pyenv and I have checked this using pyenv install --list.

Steps to reproduce the error

I have a PowerShell script to install the latest version of pyenv-win atm using (3.1.1) and add environment variables

pip install pyenv-win --target $HOME\\.pyenv --no-user --upgrade

#Adding PYENV, PYENV_HOME and PYENV_ROOT to your Environment Variables

[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")

#Adding the following paths to your USER PATH variable in order to access the pyenv command

[System.Environment]::SetEnvironmentVariable('path', $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" + $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")

#check if pyenv installed 
& pyenv --version

I know that pyenv-win has been successfully installed as I get the current version 3.1.1 output to the terminal. I also double-check by running pyenv install --list which shows all compatible versions of python.

I have another PowerShell which installs python version and creates a virtual environment (snippet of powershell script )

& pyenv rehash
& pyenv update
& pyenv install 3.8.1
& pyenv local 3.8.1
& pyenv rehash

when running this script am getting the MSI error. Sometimes it lists different components missing for example error installing "dev_d or "doc" but always has something to do with MSI.

Things I have tried

  • run vs code in admin
  • try multiple python versions

Solution

  • Update

    Found a workaround for this issue (The error is caused due to user and system variables configured). What worked for me is to download pyenv through Chocolatey as it sets and configures your system and user variables automatically. After doing this when running the following PowerShell script, I could install Python 3.8.1 without any issues.

    & pyenv rehash
    & pyenv update
    & pyenv install 3.8.1
    & pyenv local 3.8.1
    & pyenv rehash