简体   繁体   中英

Can't get pip to work after installing newer python

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM