How to make python turtle works in Jupyter Notebook
In the text book “Think Python”, module 4 starts with these sentense: It introduces the turtle module, which allows you to create images using turtle graphics. The turtle module is included in most Python installations, but if you are running Python using PythonAnywhere, you won’t be able to run the turtle examples (at least you couldn’t when I wrote this). This means, when we using other python environment such as Jupyter Notebook, we can not run there codes successfully.
But we can solve this problem by installing two modules.
First step:
$ pip install ipyturtle
$ jupyter nbextension enable --py --sys-prefix ipyturtle
Second step:
$ git clone https://github.com/gkvoelkl/ipython-turtle-widget.git
$ cd ipython-turtle-widget
$ pip install -e .
$ jupyter nbextension install --py --symlink --sys-prefix ipyturtle
$ jupyter nbextension enable --py --sys-prefix ipyturtle
Then you can run the turtle command when you testing the turtle coding. And you can see the sketch right below the cell.