pip looking in wrong folder

Question:

My issue requires some backstory.

I was having some troubles with pip, so I reinstalled Python. After the reinstall pip began to work, but Pycharm, my IDE, could no longer find Python. When I reinstalled Python it created a new folder for itself (Python310), but Pycharm kept looking in the old folder (Python39). I couldn’t figure out how to get Pycharm to look in the new folder. Even deleting and reinstalling it did nothing.

So, I renamed Python310 to Python39 and changed the PATH. Now Pycharm can find Python. But pip has developed a new and exciting error. When I try to use it I get the following message:

Fatal error in launcher: Unable to create process using '"C:UsersuserAppDataLocalProgramsPythonPython310python.exe" "C:UsersuserAppDataLocalProgramsPythonPython39Scriptspip.exe" install numpy': The system cannot find the file specified.

If I read this correctly pip is still trying to look in Python310. Would you please tell me what I need to do to get pip to looking in the right place?

Asked By: MrZJunior

||

Answers:

try to uninstall all of the existing python versions. and install it again. using any of application allow you to delete most of files, so to prevent error when re-install .

So, to start. You don’t fix this by renaming the folder where the interpreter resides. Even if that worked, it’s not a fix. The name will say one thing, but it’s actual version, compatible libraries, and anything else tied to the version number would be incorrect.

If you take a close look at the error message from pip, it tells us what’s wrong.

Fatal error in launcher: Unable to create process using ‘"C:UsersuserAppDataLocalProgramsPythonPython310python.exe" "C:UsersuserAppDataLocalProgramsPythonPython39Scriptspip.exe" install numpy’: The system cannot find the file specified.

You renamed the directory, so your IDE can find it, but pip and everything else using the Python interpreter is still configured to look in the Python39 directory to find it.

The problem you are having is that your IDE, PyCharm, needs to be configured for your project. You have to tell it where the Python interpreter is. The simple solution, you can rename your your Python folder back to it’s original state, and add it to your project.

  1. Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project | Python Interpreter. Click the Add Interpreter link next to the list of the available interpreters.

  2. Expand the list of the available interpreters and click the Show All link.

  3. Select the target interpreter.
    In your case, look for the one with this file path: "C:UsersuserAppDataLocalProgramsPythonPython310python.exe"

I would recommend going one step futher and create an interpreter in a virtual environment. Especially if you are interested in Python beyond a very casual hobby. They are unavoidable.

This link is a good source and can help you with this:

https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#interpreter

There, you will find screenshots that follow the steps I listed above. There are also detailed instructions on how to create and add a new interpreter in a virtual environment. The relevant headings are as follows:

  • Configure a Python interpreter
  • Python interpreters in PyCharm
  • Setting an existing Python interpreter
  • Creating a new Python interpreter

The rest of the content is great as well, and may help answer questions you didn’t know you had.

Answered By: nstvnsn

Option 1:

delete and reinstall again. and then when creating a project it should prompt you to pick a basic interpreter, choose python310 or whatever version you’re using.

Option 2:

use a different IDE.

Answered By: BurnDownTheWorld
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.