How to run a file in IPython console as default instead of terminal?(如何在 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?
推荐答案
简答:
- 转到
文件 >默认设置 >构建、执行、部署 >控制台
并选择Use Ipython if available
- 转到
运行 >编辑配置
并选择Show command line after
- Go to
File > Default settings > Build, Execution, Deployment > Console
and selectUse Ipython if available
- Go to
Run > Edit Configurations
and selectShow 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:
转到
文件 >默认设置 >构建、执行、部署 >控制台
并确保选择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 控制台中默认运行文件而不是终端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 IPython 控制台中默认运行文件而不是终端


- 我如何透明地重定向一个Python导入? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01