如何在 IPython 控制台中默认运行文件而不是终端? [英] How to run a file in IPython console as default instead of terminal?

查看:32
本文介绍了如何在 IPython 控制台中默认运行文件而不是终端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I started a new project in PyCharm. I have Anaconda 3.6 installed. So, in PyCharm, I selected the Anaconda python.exe as project interpreter.

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

When I first ran PyCharm, it used the IPython console as "default" console to run my script. Then I restarted my PC and now PyCharm uses the terminal when I run my scripts. Why? I don't want to use the terminal, coming from Anaconda Spyder IDE. I'm used to IPython, I like it and I want to use it.

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

How can I completely disable the terminal and use only the IPython console?

推荐答案

简答:

  1. 转到 文件 >默认设置 >构建、执行、部署 >控制台并选择Use Ipython if available
  2. 转到 运行 >编辑配置并选择Show command line after
  1. Go to File > Default settings > Build, Execution, Deployment > Console and select Use Ipython if available
  2. Go to Run > Edit Configurations and select Show command line afterwards

提示:使用 ALT + SHIFT + E

Tip: Run selected parts of your code with ALT + SHIFT + E

详情:

如果您选择 Anaconda 作为项目解释器,IPython 很可能会成为选定的控制台,即使它的外观和行为都不像您在 Spyder 中使用的 IPython 控制台:

If you've selected Anaconda as the project interpreter, IPython will most likely be the selected console even though it neither looks nor behaves like the IPython console you are used to in Spyder:

与 Spyder 不同,PyCharm 没有图形指示器,表明这是一个 IPython 控制台.

Unlike Spyder, PyCharm has no graphical indicator showing that this is an IPython console.

要确保它是一个 IPython 控制台并使其行为或多或少类似于您在 Spyder 中使用的 IPython 控制台,您应该遵循以下两个步骤:

To make sure it's an IPython console and make it behave more or less like the IPython console you are used to from Spyder, you should follow these two steps:

  1. 转到 文件 >默认设置 >构建、执行、部署 >控制台 并确保选择Use IPython if available.

转到 运行 >编辑配置并选择Show command line after

现在您可以使用 ALT+SHIFT+E 运行代码的选定部分,或多或少与 Spyder 中的一样.

Now you can run selected parts of your code with ALT+SHIFT+E more or less exactly like in Spyder.

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

If this doesn't do the trick, you should check out these other posts on SO:

执行后与程序交互

在pycharm中禁用ipython控制台

这篇关于如何在 IPython 控制台中默认运行文件而不是终端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆