Search code examples
pythonpippyenv

Once a Python upgraded to a new version how do you change the path where to Pip install installs?


I've installed a newer version of Python under wsl2 using:

pyenv install 3.9.6 pyenv global 3.9.6

Before I was using 3.8

When I pip install it still looks in the previous pip path related to Python 3.8.5. for already installed packages:

/home/ludo915/.local/lib/python3.8/site-packages

How do I update the path to where pip install installs packages and what exactly am I supposed to set it to?

Ludo


Solution

  • How do I update the path to where pip install installs packages

    Is the wrong question. There should be one installation of pip for each python installation that you have. Invoking the correct pip for the corresponding python version will automatically install to the correct site-packages directory.

    I am not too familiar with pyenv, but a fail proof advice is to invoke pip using your python interpreter like

    python -m pip install
    

    You can replace python with the interpreter that you want to use specifically. If python --version already shows that it points to 3.9, then you should be good to go. Otherwise, you might need to do python3.9 -m pip install