Thonny and Jupyter

1,802 views
Skip to first unread message

Michael Brenner

unread,
Sep 15, 2019, 12:11:23 PM9/15/19
to thonny
I want my students to use Thonny for their own programming, but I also want to use Jupyter notebooks as an interactive textbook where they can read up on the concepts and solve smallish example problems. Is there a recommended way to bring both worlds together? In particular I would love not to have to install separate Pythons for Thonny and Jupyter.
Thanks, 
  Michael
P.S. I'm absolutely delighted by the new version(s) of Thonny! 

Darth Dan

unread,
Sep 15, 2019, 1:10:35 PM9/15/19
to thonny
I used Thonny's built-in Python Compiler with Jupyter. In an hour or so I will get home and be able to say more exactly what I did, but it basically involved starting the server directly from Thonny pip shell and making a .bat file to start the browser with Jupyter client.

Austin Bart

unread,
Sep 15, 2019, 1:34:59 PM9/15/19
to thonny
Here are the instructions I give my students:

The following instructions will help you install Jupyter Notebooks from within Thonny.

  1. Open Thonny
  2. In the top menu bar, click "Tools" and then "Manage Packages"
  3. In the window that appears, type "jupyter" into the search bar and click "Find packages from Pypi".
  4. In the bottom left, click the "Install" button
  5. The installation should proceed, but may take several minutes.
  6. Once complete, close the "Manage Packages" window
  7. In the console at the bottom, type the following:
> !jupyter notebook
After a short delay, the Jupyter Notebook environment should open in your browser.


~Cory

Darth Dan

unread,
Sep 15, 2019, 4:26:41 PM9/15/19
to thonny
Honestly, installing Jupyter can be done perfectly fine from Thonny's built-in pip terminal, but I guess that "manage packages" trick works too.

Now for running it, you can make a .bat file with the following code:

C:\Users\%username%\.thonny\BundledPython36\Scripts\jupyter-notebook.exe

This will run Jupyter with (hopefully) your default browser. If it does not (my case), you can do sometihing like this:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" file:///C:/Users/%username%/AppData/Roaming/jupyter/runtime/nbserver-16220-open.html
C:\Users\%username%\.thonny\BundledPython36\Scripts\jupyter-notebook.exe --no-browser

Will take a few refreshes before it gets going, however, and Thonny must be running during the process.

If this fails (and it sometimes does), you'd have to start Jupyter Notebook from Thonny Pip shell, with that same "!jupyter notebook" command, optionally add --no-browser.

A failsafe way to do thsi would be to somehow configure your CMD the same way Thonny configures its pip shell, but last time I asked, noone knew how to do this. Maybe something changed?

Darth Dan

unread,
Sep 15, 2019, 4:29:21 PM9/15/19
to thonny
This is the best reply I got back then:
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/thonny/Ro14tJd1piE

Unfortunately it doesn't seem t work with Jupyter for some reason.

Michael Brenner

unread,
Nov 25, 2019, 3:28:10 PM11/25/19
to tho...@googlegroups.com
I'm still struggling with making Thonny and Jupyter play nicely
together.  Maybe somebody here can help. Here's where I am:

I've installed jupyter and jupyterlab via pip3 in the Thonny shell. I
can start JupyterLab by typing "!jupyter lab &" in the REPL. So far so
good, but there are two problems:

1) Since I want to give this version of Thonny to my students, I
installed it on a USB device (like they will do). However, JupyterLab
uses the C: drive as its working directory and cannot change to a
directory on another drive.
I found out how to change the working directory: by creating and editing
a Jupyter config file.  But this config file, again, resides on C: which
I cannot touch on my students' machines.  Furthermore, on every machine
USB drives get different device letters, so I wouldn't know what to put
into the path in the config file.

Obviously, this is mainly a Jupyter problem - but has anybody here
experienced the same thing and found a workaround?

2) Installing Jupyter seems to destroy the portability of Thonny: When I
move the Thonny folder to another directory (which is what my students
will do) Jupyter can't be started anymore. As soon as I put it back in
its original path it works again.

Again, this is surely not the fault of Thonny. But does anybody know to
work around this?

This shouldn't be so hard! All I want is to prepare a portable zip file
that includes Thonny and Jupyter and that my students can run both at
school and at home. How do other people do this?

Aivar Annamaa

unread,
Nov 25, 2019, 3:58:12 PM11/25/19
to thonny
Maybe you can tweak Jupyter dynamically by setting JUPYTER_CONFIG_DIR environment variable in Thonny's customize script:
Reply all
Reply to author
Forward
0 new messages