indynt
indynt

Reputation: 111

How to resolve "Invalid Python interpreter name 'python.exe'!" error in PyCharm

I'm trying to add my Python interpreter to PyCharm but whenever I navigate to python.exe and click Ok it says Invalid Python interpeter name 'python.exe'! (the spelling mistake for interpeter is how it's spelled in the dialog that appears)

I installed Python through the Microsoft app store. The interpreter is located at ~\AppData\Local\Microsoft\WindowsApps\python.exe. This is the path I navigate to when selecting the interpreter in PyCharm. There are also python3.exe and python3.7.exe but those don't work either. I can run python from the command line and it behaves as expected.

Upvotes: 11

Views: 24104

Answers (5)

Le Sir Dog
Le Sir Dog

Reputation: 135

If you're adding an already existing virtual environment, it may sound dumb but check that the python executable does exist. If it's a symlink, it should point to a valid location in your system.

In my case, I had overwritten the already existing python executable with a new python executable created by clicking the "new" option in the virtual environment creation by mistake, and the result was an incomplete virtual environment setup in which the python executable was a symlink to a non-existing python executable. Recreating the virtual environment from scratch and using it as an "existing" virtual environment solved the issue.

I know these are basic checks, but hopefully this helps someone out there who rushed for an answer.

Upvotes: 0

Behrooz Ostadaghaee
Behrooz Ostadaghaee

Reputation: 91

Remove the interpreter (by using minus sign) and add it again!

Upvotes: 1

Harald
Harald

Reputation: 49

I got the same error message when I imported a project of an existing virtual environment to pyCharm. Though the name and path of the exe was correct, pyCharm did not accept it. My solution was to remove the Interpreter in pyCharm and to add it again. Then the Error was gone. Perhaps that can help someone ...

Upvotes: 3

Bikramjeet Singh
Bikramjeet Singh

Reputation: 186

In case anyone else is still facing this issue, reinstalling PyCharm did the trick for me.

Upvotes: -1

Rafael Zayas
Rafael Zayas

Reputation: 2461

The EAP (Early Access Program) build Pavel suggests did not work for me. I hope this gets sorted out in PY-33406 as Pavel suggests.

In the responses for that issue, the thing that worked for me is included. I created a virtual environment using venv and was able to use that python interpreter. As it says on that page...

  • Open the windows prompt
  • Go to the project root: cd X:\path\to\project
  • Type python -m venv venv
  • Chose "existing interpreter" instead of creating a new venv using Pycharm and pick the Python binary from the virtualenv you created in the previous step

Hope that helps, happy to update this to add more detail if not.

Upvotes: 1

Related Questions