1

(I have deleted the prev so I think you can find it in the edit)


Edit

So following what bad_coder told in the comments as well as most of the answers in the link he shared, I clicked the "option Show All" and I got this instead

1)

enter image description here

The only thing that makes sense here is to click that "+" button and so I clicked it

2)

enter image description here

Now am I supposed to replace the highlighted part with the path (in other words what I got after typing "where python" in cmd)

3)

enter image description here

This is what I found. So which one am I supposed to copy and paste in the highlighted part? Also in (2) should I click "inherit global site package" and "make available to all projects"?

7
  • 1
    It appears to me you have Python. It might be a matter of telling PyCharm where to find it. Commented Jul 29, 2021 at 17:40
  • 1
    To find a previous interpreter installation see the instructions in this thread How can I find where Python is installed on Windows? Commented Jul 29, 2021 at 18:08
  • 1
    @AdilMohammed the trick is simple, first go to File -> Settings -> Project ->Project Interpreter (there click on the cog or the drop-down list and the option Show All navigate to the file on disk and choose the python.exe file). Afterwards that interpreter is available to be chosen in the run configurations. (But notice that if you have several different projects choosing the interpreter has to be done for every project but only once). Commented Jul 29, 2021 at 19:02
  • 1
    Wait i just clicked Ok by mistake, now it works... wow all I had to do was click ok?? I did change the file location to a folder called Python before clicking OK, but if it works I guess that means it works Commented Jul 31, 2021 at 10:50
  • 1
    @AdilMohammed yes, when there's a dialogue with a button saying Yes or Submit below it the settings are only committed after pressing. That's the common UX (user experience) in all interfaces nowadays. Commented Jul 31, 2021 at 23:05

2 Answers 2

3

In step 1. you open python as an app. This essentially opens a command prompt and executes the python.exe loading Python. -> So you do have Python installed.

This is technically the same you do in step 2, but by referencing a built-in short-name for python. The short-name could also be "python", but this requires you to add the installation to the path variable in Windows, as this finds the python.exe-file. (This is why you see the issue in step 4, because the folder is not referenced in the PATH variable.)

In step 3. PyCharm is looking for installed versions of Python, but because you do not have the installation path referenced in your path environment variable, it cannot find the installation. This you would then need to help do manually.

How to resolve this:

There are a number of options for this, but here are some of them:

  1. You select to add python to the PATH variable during installation, which is the option at the bottom of the very first screen at installation. (You would need to uninstall python and reinstall it again in order to use this option.)

  2. You need to find out where your Python is installed and add this folder to the path variable, meaning that PyCharm can detect it once PyCharm is restarted. The easiest way for this is to right-click the option from your step 1 and go to file location. This provides you the path, which you can either add to the PATH variable in Windows

  3. Alternatively you can use the method from the 2nd solution to get the path and then using it to configure an interpreter in PyCharm (Link: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#add-existing-interpreter)

Personally, I would in your case reinstall Python and Add Python to PATH variable during installation, as this should ensure that the PATH environment variable is correct.

Sign up to request clarification or add additional context in comments.

3 Comments

In the 1st option, i uninstalled from, I think the installer thing, but when I reinstalled i couldn't get any PATH variable option
No wait, is it "Add Python 3.9 to PATH"? I think it should be it
@AdilMohammed That is exactly it. :) (I did not add the 3.9-part to my description, as I was not certain which version you were installing. Probably should have...)
1

I had the same issue with a computer a while ago. I ended up having to uninstall pycharm and reinstall it. Then for some reason, it popped up. Also, make a new project and change the settings of the project.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.