[英]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. Python3 默认安装在 MacBook 上。
which python3
will output /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
which python3
将输出/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Great, so that's my SDK to put into IntelliJ IDEA, one should think.太好了,这就是我要放入 IntelliJ IDEA 的 SDK,你应该想一想。
I have the Python plugin for IDEA.我有适用于 IDEA 的 Python 插件。 However, I can't run Python files.但是,我无法运行 Python 文件。 So I try to change the configuration and set it to the above PATH for the Python interpreter.所以我尝试更改配置并将其设置为 Python 解释器的上述 PATH。
However, still nothing.然而,还是什么都没有。 Trying to run the Python file inside IDEA will prompt a new configuration?尝试运行IDEA里面的Python文件会提示新配置?
I can run the script just file doing python3 script.py
in the terminal?我可以只在终端中执行python3 script.py
文件来运行脚本吗? I know the path for the Python3 library, yet, IDEA doesn't recognise it at all and doesn't save the configuration.我知道 Python3 库的路径,但是,IDEA 根本无法识别它并且不保存配置。
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?我什至尝试使用 IDEA 内部工具创建 Python 3.6.2 虚拟环境 - 同样的事情? It doesn't allow me to run the Python3 script from inside IDEA.它不允许我从 IDEA 内部运行 Python3 脚本。
Should I use python from usr/bin/python
?我应该使用usr/bin/python
吗? If I cd there, I can see Python3.如果我在那里 cd,我可以看到 Python3。 But inside IDEA, i only have access to Python2..但在 IDEA 中,我只能访问 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.通过 pyenv 安装 Python 3.8.1 后,我现在推荐使用 Homebrew(参见https://github.com/pyenv/pyenv ),我执行以下操作将此版本添加到 IntelliJ IDEA。
Updated for IntelliJ IDEA 2019.3.3针对 IntelliJ IDEA 2019.3.3 更新
在 IDEA 的菜单中试试这个: File -> Settings -> Project: Name of project -> Project Interpreter
,从上面的窗口中你可以选择解释器版本或 virtualenv。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.