I am running PyCharm Community 2018.2 on macOS 10.13.6
II know that macOS comes with Python preinstalled. I believe that when you go to https://www.python.org/
, download the python-3.7.0-macosx10.9.pkg
file, and run it to install Python, it installs Python, a second time, but in a different location.
I believe that the location of the pre-installed macOS Python is: usr/bin/python
. I know this by opening Terminal and typing which python
. I also believe that if I want to see the location that the .pkg file installed Python, I'd need to type in: which python3
. When I do that, I get: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
.
I created a new Python project a few weeks back that just contains one .py file, and that's it. I did some file clean-up to get better organized, and I moved that project folder into a new folder. Today when I opened PyCharm, I went to Open: and I searched for and selected that project folder and clicked Ok. It loaded, and I could see my python code in the .py file. The 'run' option was grayed out, and I saw the warning message: Invalid python interpreter selected for the project. --- Configure Python interpreter
.
I clicked to configure the Python interpreter. I had done this once before, but I did not understand it very well then, and I still do not. I see that I can click the sprocket at the end of the line labeled Project interpreter, and select "Add..."
Then I see two main options:
At this point, I just get really confused.
/usr/local/bin/python3.7
It seems like no matter where I try to find the correct interpreter, I get the same error message: Cannot setup a python SDK at Python 2.7 (Project_Folder) (/Library/Framework.../venv/Scripts/python.exe)
If I select "Existing environment" and navigate to /Library/Frameworks/Python.framework/Versions/3.7/Python
... I get the error.
If I select "Existing environment" and navigate to /usr/bin/python
... it seems to resolve the issue, and I can run the .py file's code again. But is that not the wrong installation of Python? Is that not using the interpreter that came with macOS? When I go to PyCharm > Preferences, the Project Interpreter is now showing as: Python 2.7 usr/bin/python.
That seems incorrect to me.
Delete .idea
folder
For New Environment:
For Existing Environment:
It's worked for me.
Good details: Here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With