1

I installed python 3.8 in a different location than 3.7, and later uninstalled 3.7 while trying to troubleshoot issues with pip. I can't get pip to respond to install any modules now. It keeps referencing its old python 3.7 location and I don't know how to make it focus on the 3.8 installation location.

Here are the errors I'm encountering:

>pip --version
Fatal error in launcher: Unable to create process using '"c:\program files\python37\python.exe"  "C:\Program Files\Python37\Scripts\pip.exe" --version': The system cannot find the file specified.

>python get-pip.py
Collecting pip
  Using cached pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
Successfully installed pip-20.1.1

Now when I call pip --version is gives me the original error. And just for more information, here are two more calls which might help troubleshoot.

>which python
/c/Users/patch/AppData/Local/Programs/Python/Python38/python

>python --version
Python 3.8.3

I just want to be able to use pip again to install modules. I'm learning some python and this pip issue is really slowing me down.

I'm open to completely uninstalling python and scrubbing the system of traces of both I just don't know what's the safest and most likely to work option.

2 Answers2

0

Use

python -m pip --version
python -m pip install PACKAGE_NAME

This will use the pip that is associated with the newer python.

I suggest using the python -m pip install command over pip install because it is more clear which python version is being used.

jkr
  • 17,119
  • 2
  • 42
  • 68
  • Ohh, you mean when I use it, to use this -m. gotcha will try that now – Rodney Winsor Jul 02 '20 at 19:37
  • 1
    I realize I should have been clearer in my answer. The `...` in the `python -m pip install command` was meant to signify the packages that you want to install. So if you wanted to install numpy, for example, you would use `python -m pip install numpy`. – jkr Jul 02 '20 at 19:39
  • That worked, thanks. anyway to make the default pip just use that since it doesn't work otherwise? – Rodney Winsor Jul 02 '20 at 19:44
  • 1
    Great, if this was the answer to your question, then please mark it with the green check mark. I personally always use the `python -m pip install` syntax because it is more clear, but to fix your environment, I would refer to the [answer below](https://stackoverflow.com/a/62703654/5666087). Virtual environments are meant to solve this issue. Look into [virtualenv](https://virtualenv.pypa.io/en/latest/installation.html#via-pip), miniconda, pyenv-win, or other solutions. – jkr Jul 02 '20 at 19:49
-1

I'd recommend scrubbing 3.7 and 3.8 from your system, then reinstalling the versions you need with pyenv (if you're using the Windows Subsystem for Linux) or pyenv-win (if not on WSL) to manage multiple Python versions. It checks the directory-specific version of Python that you've set before deciding which version's executables to use for Python, pip, etc. This solution will also work in the long term for future versions of Python you may want to install.

Future installations using pyenv or pyenv-win would involve commands like pyenv install 3.8.1. For a full list of available versions you can run pyenv install -l.

@jakub's solution will work if you want an immediate, but short-term, fix.

jidicula
  • 3,454
  • 1
  • 17
  • 38
  • 1
    I agree, and beginners (everyone, really) should get in the habit of using virtual environments to keep their python installations neat. Because I mostly use python for scientific computing, I like to use Miniconda for virtual environments, but of course other solutions exist. – jkr Jul 02 '20 at 19:28
  • 1
    Exactly – as usual, there's a relevant XKCD about how Python environments can quickly get messy: https://xkcd.com/1987/ – jidicula Jul 02 '20 at 19:29