简体   繁体   中英

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..

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

在 IDEA 的菜单中试试这个: File -> Settings -> Project: Name of project -> Project Interpreter ,从上面的窗口中你可以选择解释器版本或 virtualenv。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM