Ipython: embed() 的彩色提示

创建于 2018-12-04  ·  10评论  ·  资料来源: ipython/ipython

import IPython; IPython.embed()对我来说没有颜色。 https://github.com/ipython/ipython/issues/9450相关但很旧。

IPython 7.1.1
蟒蛇 3.6.6
Ubuntu 18.04

最有用的评论

对于偶然发现此问题的任何人,我都能够像这样修复它:

IPython.embed(colors="neutral")

所有10条评论

同样在这里。

iPython 7.1.1
蟒蛇 3.7.0,
Mac OS X 10.14

也在这里。

IPython 7.2.0
蟒蛇 3.6.6
RHEL 7.4 / Mac 操作系统 10.14

这个问题似乎源于#11265。

https://github.com/ipython/ipython/blob/0acd580fce7192044a6f846dd09d31d498018347/IPython/terminal/embed.py#L369 -L371

为什么现在默认为“NoColor”隐式分配颜色?

对于肮脏的修复,我设置

IPython.embed(using=False)

这显然是滥用代码,并使用IPython.core.async_helpers._AsyncIORunner而不是IPython.core.async_helpers._pseudo_sync_runner 。 对于我的特殊情况,我不确定可能会产生什么意想不到的副作用。

我们也遇到了这个问题,这是阻止我们从 5.x 升级的原因之一......我们非常感谢对此问题的修复。

是的,这是一种奇怪的行为。 在我的情况下,整个配置在没有@topherocity的解决方案的情况下被覆盖

好像还是有问题。

在 Windows 和 Linux 上仍然是一个问题。 顺便说一句,您可以在修复此问题之前使用%colors linux%colors lightbg

在 Windows 和 Linux 上仍然是一个问题。 顺便说一句,您可以在修复此问题之前使用%colors linux%colors lightbg

@Arnie97你能详细说明一下吗? 我不知道你所说的“使用%colors linux ”是什么意思。

在嵌入式终端中键入“%colors linux”,然后按 Enter。

对于偶然发现此问题的任何人,我都能够像这样修复它:

IPython.embed(colors="neutral")

感谢@banool!

我希望这也可以帮助其他人,但这里是默认的颜色选择列表。 这是从当您尝试使用不受支持的颜色特征时引发的异常中获取的。

The 'colors' trait of an InteractiveShellEmbed instance must be any of ['Neutral', 'NoColor', 'LightBG', 'Linux'], but a value of True <class 'bool'> was specified

另一个例子是使用"Linux"颜色特性。 我得到了一个使用 Linux 颜色的漂亮闪亮的彩色终端。

$ python -c 'import IPython; IPython.embed(colors="Linux")'
Python 3.7.4 (default, Aug 13 2019, 15:17:50) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:    
此页面是否有帮助?
0 / 5 - 0 等级