简体   繁体   English

如何在 Google Colab 中打开交互式 Python 提示?

[英]How to open an interactive Python prompt in Google Colab?

How does one open an interactive Python console/shell/prompt within Google Colab?如何在 Google Colab 中打开交互式 Python 控制台/外壳/提示? Is it possible?可能吗? An iPython prompt would be ideal but a regular prompt would suffice. iPython 提示将是理想的,但常规提示就足够了。

Also, it would be significantly more useful if the console's interpreter shared access to the variables/state with the Colab notebook's kernel.此外,如果控制台的解释器与 Colab 笔记本的 kernel 共享对变量/状态的访问,这将更加有用。

!jupyter console --existing appears to hang with no output because it is waiting to acquire the GIL in the same process as the notebook's runtime that is executing the, magic. !jupyter console --existing似乎没有 output 挂起,因为它正在等待在与执行魔法的笔记本运行时相同的进程中获取 GIL。 which isn't going to give it up until the.这不会放弃它,直到。 is done.已经完成了。 For the same reason I don't think it's going to be easy to get a subprocess invocation to share state with the notebook's runtime.出于同样的原因,我认为通过子进程调用与笔记本的运行时共享 state 并不容易。 Obvs.观察。 you could program your own input() + eval() in a loop to simulate a py prompt that shared the env with your notebook.您可以在循环中编写自己的 input() + eval() 以模拟与笔记本共享环境的 py 提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM