cbll
cbll

Reputation: 7219

How do I set up Python 3 with IntelliJ IDEA on OSX?

I'm highly confused about this. Python3 is installed per default on the MacBook.

which python3 will output /Library/Frameworks/Python.framework/Versions/3.6/bin/python3

Great, so that's my SDK to put into IntelliJ IDEA, one should think.

I have the Python plugin for IDEA. However, I can't run Python files. So I try to change the configuration and set it to the above PATH for the Python interpreter.

However, still nothing. Trying to run the Python file inside IDEA will prompt a new configuration?

I can run the script just file doing python3 script.py in the terminal? I know the path for the Python3 library, yet, IDEA doesn't recognise it at all and doesn't save the configuration.

What am I doing wrong in this process? This should be fairly easy to set up but turns out it isn't :)

I even tried to create a Python 3.6.2 virtual environment with the IDEA internal tool - same thing? It doesn't allow me to run the Python3 script from inside IDEA.

Should I use python from usr/bin/python? If I cd there, I can see Python3. But inside IDEA, i only have access to Python2..

Upvotes: 1

Views: 6333

Answers (2)

jkwuc89
jkwuc89

Reputation: 1415

After installing Python 3.8.1 via pyenv which I now recommend over using Homebrew (see https://github.com/pyenv/pyenv), I did the following to add this version to IntelliJ IDEA.

  1. Close all open projects. This will display the Welcome to IntelliJ IDEA window listing recent projects along the left.
  2. Click on Configure -> Structure for New Projects
  3. Click on SDKs under Platform Settings along the left
  4. Click on the + sign above the SDK list and select Python SDK
  5. From the Add Python Interpreter window, select System Interpreter
  6. Click on the ... button to the right of the Interpreter drop down and browse to $HOME/.pyenv/versions/3.8.1/bin/python. Replace 3.8.1 with the desired Python version if you want to configure another version.

Updated for IntelliJ IDEA 2019.3.3

Upvotes: 4

Igor  Lavrynenko
Igor Lavrynenko

Reputation: 171

Try this in menu of IDEA: File -> Settings -> Project: Name of project -> Project Interpreter and from above in the window you can choice interpreter version or virtualenv.

Upvotes: 2

Related Questions