我试着在不同的云(google collab或我们学校可用的服务器)中使用python jupyter笔记本中的一只乌龟。在这两台服务器上,可以安装或已经安装了该模块:
%pip install mobilechelonian
收益率(前三行):
Requirement already satisfied: mobilechelonian in /opt/conda/lib/python3.8/site-packages (0.5)
Requirement already satisfied: ipywidgets>=7.0.0 in /opt/conda/lib/python3.8/site-packages (from mobilechelonian) (7.6.3)
Requirement already satisfied: IPython in /opt/conda/lib/python3.8/site-packages (from mobilechelonian) (7.19.0)
Requirement already satisfied: pygments in /opt/conda/lib/python3.8/site-packages (from IPython->mobilechelonian) (2.7.2)
我只是将演示代码复制并粘贴到一个单元格中:
from mobilechelonian import Turtle
t = Turtle()
t.speed(5)
colours=["red","blue","yellow","brown","black","purple","green"]
t.penup(); t.left(90); t.forward(200);t.right(90);t.pendown()
for i in range (0,18):
t.pencolor(colours[i%7])
t.right(20)
t.forward(50)
t.right(180)
t.home()
结果不是waited colored polygon,而是一个具有输出的单元格:
Turtle()
感谢您提供解决此问题的建议。
发布于 2021-02-17 09:51:15
由于某些原因,当从经典的jupyter笔记本启动时,notebook会显示绘图,而从jupyterlab启动时会失败。
https://stackoverflow.com/questions/66239145
复制