Google Colaboratory

1,684 views
Skip to first unread message

Wolfgang Christian

unread,
Mar 31, 2019, 7:58:39 AM3/31/19
to VPython-users
Has anyone successfully configured a Jupyther Collaboratory to run the Bruce's VPhython exampes?

Wolfgang  

mattw...@gmail.com

unread,
Apr 2, 2019, 6:02:31 PM4/2/19
to VPython-users
Hi,

I haven't but could imagine that it will take some doing to make it work. Even some fairly "stock" packages like ipywidgets that involve front/back end communication were only added very recently and are somewhat buggy. 

VPython in the notebook relies on either the notebook's built in websocket server to communicate from python to javascript and back or a separate websocket server set up by vpython. The latter is causing some issues on binder so I wouldn't be surprised if it caused issues in colab.

Matt Craig

John

unread,
Apr 3, 2019, 7:41:00 AM4/3/19
to VPython-users
I tried using colaboratory for the first time. I notice that it is using older versions of ipykernel and IPython packages.

For ipykernel it was version 4.6 and for IPython it was 5.5. You can determine this in python in colaboratory notebook cell by printing

   ipykernel.__version__

   IPython.__version__

So maybe installing a previous version of vpython might work. 

   pip install vpython==7.4.6

I am not a colaboratory user and I had problems connecting to the kernel so I wasn't able to test this.

John

Christian, Wolfgang

unread,
Apr 3, 2019, 8:04:21 AM4/3/19
to vpytho...@googlegroups.com

John –

 

Thanks for the suggestion.  I tried using “pip install vpython==7.4.6” and that did not work.  I will develop VPhython material using Jupyter Lab while I wait for CoLab to catch up.

 

Wolfgang

Hossein Mokhtarzadeh

unread,
Feb 12, 2022, 6:26:15 AM2/12/22
to VPython-users
Hi all,

I used a trick to run VPython on Colab but it is not good enough as you cannot manipulate the code inside Colab yet. For instance, I would like to do some calculations in another cell and bring the outcomes to VPython to do the animation which is not possible with the way I am showing here. Any suggestion would be appreciated!
Cheers,
Hossein
colab.png

John

unread,
Feb 14, 2022, 12:46:55 AM2/14/22
to VPython-users
I don't think anyone has succeeded in running vpython in google colaboratory like in a Jupyter Notebook. If you are looking to running a vpython jupyter notebook in the cloud you can try running it in mybinder.org . Here is a link to jupyterlab running in the cloud with several vpython demo programs as notebooks.


Just click on this link to launch jupyterlab in the cloud using mybinder.org. You can then try opening one of the notebooks and running the vpython code.

To set this up all you do is create a github repository with your jupyter notebooks and a file called binder/requirements.txt and a file called postBuild like in this repository. 


Then past your github repository name in mybinder.org website to launch it on google cloud. Another option is to try running vpython on jupyterhub.


If you are just looking to run on google colab I suppose you could also try launching jupyterlab on google colab as explained here.


and  here


and then try running vpython on jupyterlab on google colab. But I don't think anyone has ever tried this, so I don't know if it will work.

John
Message has been deleted

Hossein Mokhtarzadeh

unread,
Feb 14, 2022, 3:56:20 AM2/14/22
to VPython-users
Many thanks, John. The  jupyterlab link using mybinder is very nice. It runs well. 

As for the rest, I will give them a try! 
Cheers,
Hossein

Aaron Titus

unread,
Feb 15, 2022, 10:21:10 AM2/15/22
to vpytho...@googlegroups.com
John, thank you for the tips.

I’ve used Google Colab with honors courses where most of my students have never coded and may never code again. For these students, not installing Anaconda was a game changer. As a result, we didn’t use VPython. However, you’ve inspired me to implement a few exercises for my class with VPython using mybinder.

AT


-- 
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vpython-users/b789eae4-f30e-4739-91fc-517eb3d32d43n%40googlegroups.com.

Physics ESG

unread,
Jan 9, 2023, 5:45:23 PM1/9/23
to VPython-users
Hello! Has anyone managed  to run and manipulate VPython in Colab? We  have been using MyBinder, but there is a limit to the number of people who can access the notebook :(

John

unread,
Jan 10, 2023, 9:28:03 PM1/10/23
to VPython-users
No I don't think it is possible. One possible workaround is to load a vpython file from webvpython.org into google colab for instance with a command.

from IPython.display import HTML
HTML(filename='GlowScriptObjects-VPython.html')

and it will display a vpython program that you can interact with in google colab like this.

webvpython_in_google_colab.jpg


See webvpython.org example programs at 


and click on the "view" of any of the demo programs and then click "Share or export this program " to view instructions on how to share a webvpython program. For the above example I chose the "Download as HTML" option and then copied the downloaded html file to my google drive share folder. I then loaded it into google colab with the following commands in some google colab notebook cells.

from google.colab import drive
drive.mount('/content/drive')

%cd /content/drive/My Drive/share/

from IPython.display import HTML
HTML(filename='GlowScriptObjects-VPython.html')

And it displayed the file GlowScriptObjects-VPython.html that I downloaded from webvpython.

Note that you can only view and interact with the webvpython file in google colab. I don't think you can manipulate the vpython content from other colab notebook cells.

You can also try other options to  "Share or export this program "  the webvpython program and load it into google colab such as using 

%%html

in a notebook cell. Then you get something like this.

webvpython_in_google_colab_ex2.jpg


John

Physics ESG

unread,
Jan 12, 2023, 10:32:22 AM1/12/23
to VPython-users
Thank you!!! It's a good solution, but I am concerned it would be confusing for the students; I think we'll try to make it work with my binder.

Steve Spicklemire

unread,
Jan 12, 2023, 10:57:32 AM1/12/23
to 'Steve Spicklemire' via VPython-users, Steve Spicklemire
You might also consider trinket. You can set up a “starter” program that students can modify and submit. Here’s an example:

https://trinket.io/glowscript/ed2641da8f

Once they edit it to their satisfaction they can “share” the URL to their individual work.

John

unread,
Jan 12, 2023, 7:17:39 PM1/12/23
to VPython-users

You can also look into JupyterHub which is similar to mybinder and VPython works on JupyterHub. Maybe your institution already uses JupyterHub and you just have to ask your IT people to install VPython on it.  JupyterHub can run on many different platforms from a single standalone computer in your office to a cluster of computers in the cloud. If you install it in the cloud then it will cost money to run it there whereas mybinder is free. Here is what the login procedure looks like for JupyterHub and once you are logged in then you are presented with the jupyterlab interface just like with mybinder.


Here are some recent tutorials for installing and running JupyterHub 


and here is the JupyterHub website.


John

John

unread,
Jan 12, 2023, 7:45:20 PM1/12/23
to VPython-users
Here are the instructions for installing JupyterHub on your own server hardware.

John

unread,
Jan 13, 2023, 1:01:42 AM1/13/23
to VPython-users
I am using a Windows 10 laptop and I managed to get JupyterHub running on my Windows System For Linux (wsl) that comes with Windows 10 or 11. So I have JupyterHub running on wsl and can access it from my browser in Windows 10 and run VPython on it.
Previously I provided instructions on how to run vpython on wsl and it is the first FAQ on the vpython.org website.


Now I verified that you can run JupyterHub on wsl on a Windows 10 computer. I found these instructions for installing JupyterHub and JupyterLab using conda.


If you have anaconda installed on wsl then you can create a JupyterHub environment in wsl ubuntu terminal with the command

conda create --name jupyterhub jupyterhub jupyterlab ipywidgets

Then after the environment is created you can activate it and install vpython and jupyterlab-vpython into this environment.

conda install -c conda-forge vpython
conda install -c conda-forge jupyterlab-vpython

Then launch JupyterHub with with the command

jupyterhub

If you encounter any problems you might need to activate systemd on wsl as described here.


otherwise you can access jupyterhub from the browser on the Windows 10 machine at the address

    localhost:8000

And you will be presented with the JupyterHub login screen and after you login you can run vpython programs in JupyterLab.

I also found this resource helpful for evaluating the different JupyterHub infrastructure options.


John

Physics ESG

unread,
Jan 20, 2023, 1:50:08 PM1/20/23
to VPython-users
Thank you Steve and John! We decided for now to stick with mybinder, since we  already tested it for a smaller group ,  but  we will try Trinket and JupyterHub (first for smaller groups). Just to be sure I understand 1- In Trinket we  provide the starter page, and then when the students click on it, it creates the individual one for them to change? 2-  Can the students work on the JupyterHub notebooks without going through the installation process themselves? Best

John

unread,
Jan 23, 2023, 11:40:42 AM1/23/23
to VPython-users
Yes students can work on JupyterHub notebooks without going through the installation process themselves. Have a look at this video on using a JupyterHub server for teaching a class.


Also checkout 


where the JupyterHub was setup and maintained by

John

Physics ESG

unread,
Jan 25, 2023, 10:26:19 AM1/25/23
to vpytho...@googlegroups.com
Great, thank you!

You received this message because you are subscribed to a topic in the Google Groups "VPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vpython-users/q0g-MuQj4Sw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vpython-users/bd67ecbb-aac5-4509-9b78-8f11d4708c78n%40googlegroups.com.

John

unread,
Jan 29, 2023, 11:06:43 AM1/29/23
to VPython-users
I will point out that it is possible to install JupyterHub locally on a Linux/Unix based system and then once it is installed and launched you can 
just enter the following IP address in a web browser and sign into JupyterHub with you Linux/Unix credentials.


Here are the instructions for installing JupyterHub locally on a Linux/Unix based system.


You will also want to have JupyterLab installed locally on the system.


You can also get JupyterHub to work locally on a Windows machine by using Windows 10 or 11 built-in Windows Subsystem for Linux.(WSL)
To enable WSL2 on Windows follow these instructions.


Then install JupyterHub and JupyterLab on this WSL2 Linux distribution and then launch JupyterHub and enter the web address


into your browser on your windows machine.

If you install JupyterHub , JupyterLab and VPython locally on your machine then you can use it locally and get a feel of how it all works together on a single computer.

If you are using WSL2 then you can connect to the JupyterHub remotely from any computer running on the same local area network. See instructions here on how to set that up.


Then anyone with a login id on the virtual linux machine can log into JupyterHub if you have configured JupyterHub to allow those users.

John

John

unread,
Jan 30, 2023, 1:30:45 PM1/30/23
to VPython-users
For deploying JupyterHub for a large number of users such as students in a class, then you would probably need to deploy it on Kubernetes. This video walks through the steps of in the JupyterHub documentation for installing JupyterHub on Kubernetes on Google Cloud (GKE) and shows it up and running on GKE.


In the video he is just following the steps in the JupyterHub installation documentation for deploying JupyterHub and he selected the option "Zero to JupyterHub for Kubernetes" and he chose the option to install it on GKE.


John

John

unread,
Feb 6, 2023, 7:45:33 AM2/6/23
to VPython-users
Another option for setting up JupyterHub is to take advantage of this free cloud computing offer from Oracle.


And once you have your free Ubuntu Cloud PC with 4 CPUs,  24 GB of RAM and 200 GB of disk storage setup along with a public IP address,
you can then install the JupyterHub deployment option "The Littlest JupyterHub" onto it.


and choose the "Install on your own server" option.


It lists some pre-requisites in order to install this option

  1. Some familiarity with the command line.

  2. A server running Ubuntu 18.04 where you have root access.

  3. At least 1GB of RAM on your server.

  4. Ability to ssh into the server & run commands from the prompt.

  5. An IP address where the server can be reached from the browsers of your target audience.

And this offer of a free Ubuntu Cloud PC seems to satisfy all of these pre-requisites. They even provide you a Public IP Address in the Oracle offer.

John
Reply all
Reply to author
Forward
0 new messages