pythonpippipenv

Pipenv error "No Python at 'C:\Python39\python.exe' "


I installed and added Python3.9 and Pip to the PATH through the installer.

python --version
# Python 3.9.7
pip --version
# pip 21.2.4 from C:\Users\{MyUserName}\AppData\Local\Programs\Python\Python39\lib\site-packages\pip (python 3.9)

I installed pipenv with pip install pipenv and pipenv --version outputs pipenv, version 2021.5.29. Although, if I try to install any package with pipenv, or just enter the pipenv shell and then run python --version, I always get No Python at 'C:\Python39\python.exe'.

Python sys path is C:\Users\{MyUserName}\AppData\Local\Programs\Python\Python39, so why does pipenv look into another folder? And how can I fix this?

I'm running all these commands in git bash.


Solution

  • For anyone running into this error, run the following to delete the virtual environment (built with the previous/future version of Python):

        cd $project_folder
        pipenv --rm
    

    Then rerun this to build your pipenv virtual environment with your new version of Python:

    pipenv install