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

查看:578
本文介绍了如何在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控制台作为默认控制台来运行我的脚本。然后我重新启动了我的PC,现在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. 转到文件>默认设置>构建,执行,部署>控制台并选择使用Ipython(如果可用)

  2. 转到运行>编辑配置并选择之后显示命令行

  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中看到这个:

I guess you are used to seeing this in Spyder:

我还猜测以下是您在控制台窗口中在PyCharm中看到的内容:

I'm also guessing that the following is what you're seeing in PyCharm in the Console Window:

与Spyder不同,PyCharm没有图形指示器显示这是一个IPython控制台。因此,为了确保它是一个IPython控制台,并使其行为或多或少像您从Spyder习惯的IPython控制台,您应该尝试遵循以下两个步骤:

Unlike Spyder, PyCharm has no graphical indicator showing that this is an IPython console. So, 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 try to follow these two steps:


  1. 转到文件>默认设置>构建,执行,部署>控制台并确保选择使用IPython(如果可用)

  1. Go to File > Default Settings > Build, Execution, Deployment > Console and make sure to select Use IPython if available.

转到运行>编辑配置并选择之后显示命令行

Go to Run > Edit Configurations and select Show command line afterwards

现在,您可以使用 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天全站免登陆