+-
如何在IPython控制台中默认运行文件而不是终端?

我在PyCharm开始了一个新项目。我安装了Anaconda 3.6。所以,在PyCharm中,我选择了Anaconda python.exe作为项目解释器。

当我第一次运行PyCharm时,它使用IPython控制台作为“默认”控制台来运行我的脚本。然后我重新启动了我的PC,现在PyCharm在我运行脚本时使用了终端。为什么?我不想使用来自Anaconda Spyder IDE的终端。我习惯了IPython,我喜欢它,我想用它。

如何完全禁用终端并仅使用IPython控制台?

35
投票

简短回答:

File > Default settings > Build, Execution, Deployment > Console并选择 Use Ipython if availableRun > Edit Configurations并选择 Show command line afterwards

提示:使用ALT + SHIFT + E运行代码的选定部分

细节:

如果您选择Anaconda作为项目解释器,IPython很可能是选定的控制台,即使它看起来既不像IPython console you are used to in Spyder也不像:

enter image description here

与Spyder不同,PyCharm has no graphical indicator表明这是一个IPython控制台。

enter image description here

为了确保它是一个IPython控制台并使其行为或多或少像您从Spyder习惯的IPython控制台,您应该遵循以下两个步骤:

File > Default Settings > Build, Execution, Deployment > Console并确保选择 Use IPython if availableenter image description hereRun > Edit Configurations并选择 Show command line afterwards enter image description here

现在,您可以使用ALT+SHIFT+E运行代码的选定部分,或多或少与Spyder完全相同。

如果这不起作用,你应该查看SO上的其他帖子:

Interacting with program after execution

Disable ipython console in pycharm