VPython on Raspberry Pi 5

249 views
Skip to first unread message

Jeffrey Yung

unread,
Jan 7, 2025, 9:53:33 AMJan 7
to VPython-users
Hi all, 

I am new to  VPython and sorry if this was a question asked before. I tried to use it on RPi 5 but I don't get any output. The browser just does not start. When I run it in the terminal, it displays "HTTP request sent; waiting for response.". Is there any additional configuration I should do. Thanks for your feedback.


Regards,
jY

John

unread,
Jan 7, 2025, 1:49:16 PMJan 7
to VPython-users
Have a look at this video tutorial on youtube from 2 years ago entitled " Raspeberry Pi LESSON 14: Installing Vpython on the Raspberry Pi".

https://www.youtube.com/watch?v=_q5t46kIC30&list=PLGs0VKk2DiYxdMjCJmcP6jt4Yw6OHK85O&index=17

See if it will work with Raspberry Pi 5 and let us know.

Jeffrey Yung

unread,
Jan 8, 2025, 1:22:41 AMJan 8
to VPython-users
Hi John,

Thanks for your reply. Yes, I watched it and check the dependency. The only different is that he was using Buster which is EOL in Jun last year. I did try to switch the window manager from Wayfire to X11, still no luck. any suggestion?


Regards,
jY
Screenshot 2025-01-08 141913.png

John

unread,
Jan 8, 2025, 3:03:41 AMJan 8
to VPython-users
I am not a Raspberry Pi user so I don't have many insights to offer. Just check that you are able to launch the chromium browser on your Raspberry Pi and that it works without vpython, that is you can browse the web using your chromium browser on Raspberry Pi. 

You can also try running jupyter lab or jupyter notebook on your Raspberry Pi. Try launching it with the command

    jupyter lab

or 
pip3 install notebook
and launch it using the command

   jupyter notebook

See if that runs in your chromium browser. If that works then you can try running vpython in a jupyter notebook from either jupyter lab or jupyter notebook. See the following link for more information.

Hope this helps.

John

unread,
Jan 8, 2025, 10:43:53 AMJan 8
to VPython-users
Further to my previous response. If you are able to launch the chromium browser on your Raspberry Pi 5, then try running the example programs from webvpython on this browser.

https://glowscript.org/#/user/GlowScriptDemos/folder/Examples/

First try run some of these vpython programs on your browser on your regular computer and then try do the same using chromium browser on Raspberry Pi. If that works then you can try running the same vpython example programs from the command line on your Raspberry Pi. The demo programs can be found on github here.

https://github.com/vpython/vpython-jupyter/tree/master/Demos_no_notebook

Just download one of the demo programs such as 'BinaryStar.py' onto your Raspberry Pi device and then run it with the command.

    python3 BinaryStar.py

You need to make sure you are using python3 when using VPython.

If you want to try these demo programs using Jupyter Notebook on Raspberry Pi then the notebook version of them can be found here.

Jeffrey Yung

unread,
Jan 8, 2025, 12:45:14 PMJan 8
to VPython-users
Hi John,

I am actually using Jupyter. It has the same issue as command line. In fact, after waiting for few hours (guess), I got the output. Considering those Glowscript demos are running fine, not sure if there is some kind of timeout happening in between the vPython output and the browser....


Regards,
jY 

John

unread,
Jan 8, 2025, 3:05:10 PMJan 8
to VPython-users
One thing you could try is to uninstall and reinstall jupyterlab-vpython extension package.

pip uninstall jupyterlab-vpython

pip install jupyterlab-vpython

Then launch jupyterlab and check that the jupyterlab-vpython extension is enabled.

   jupyter lab

Then click on the extensions icon on the left hand side and check that jupyterlab-vpython is enabled. Then try running vpython in a notebook in jupyter lab.

However, I am not sure if this will work on Raspberry Pi 5 with the ARM architecture. The reason is that when VPython was last released in 2024, it was built for use one the platforms 
        python-version: [3.11, 3.12]
        platform: [ubuntu-latest, macos-latest, windows-latest]


But the Arm based github actions didn't appear until later in 2024.


So that is probably why it is so slow. There probably wasn't an image of vpython built for the Arm Architecture. So maybe you can add an issue to jupyter-vpython and request that vpython include the Arm Architecture in their build process for the next vpython release.

John

unread,
Jan 8, 2025, 5:33:40 PMJan 8
to VPython-users
If the above didn't work, then try uninstal vpython then install vpython from the github repository. If you don't have git installed you can install git via apt-get install git .

pip uninstall vpython

cd vpython-jupyter
python3 setup.py install

Then after it installs (probably it will say vpython version 0.0.0) launch jupyter lab and see if vpython works in a jupyter lab notebook.



Jeffrey Yung

unread,
Jan 9, 2025, 10:27:45 AMJan 9
to VPython-users
Hi John,

I tried both and also switch back and forth between Wayland and X, still have the issue unfortunately. The Python version is 3.11. BTW, the issue is not just launching via Jupyter but even using command line to execute the py.  


Regards,
jY

John

unread,
Jan 9, 2025, 12:40:12 PMJan 9
to VPython-users
Try using Ubuntu operating system on Raspberry Pi. See this tutorial video on how to install Ubuntu in 8 minutes on Raspberry Pi 5.

https://www.youtube.com/watch?v=5CBYGz_mO9U

The Vpython build scripts target the Ubuntu, MacOS and Windows operating systems. So maybe if you install Ubuntu on you Raspberry Pi 5 you can get VPython to work on it.
The VPython build script on github contained the following 2 lines for the targeted operating systems.

        python-version: [3.11, 3.12]
        platform: [ubuntu-latest, macos-latest, windows-latest]

From this build script file on github.

John

Jeffrey Yung

unread,
Jan 9, 2025, 10:46:55 PMJan 9
to VPython-users
Hi John,

Will try. BTW, I captured the error message when running the code in terminal. It seems that the issue is related to dbus. Nevertheless, eventually after few hours, the output was shown in the browser, then I captured the information below

Looking up localhost:38567
Making HTTP connection to localhost:38567
Sending HTTP request.

HTTP request sent; waiting for response.
Alert!: Socket read failed (too many tries).
Connection interrupted.

lynx: Can't access startfile http://localhost:38567/
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 59554)
Traceback (most recent call last):
  File "/usr/lib/python3.11/socketserver.py", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.11/socketserver.py", line 348, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.11/socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.11/socketserver.py", line 755, in __init__
    self.handle()
  File "/usr/lib/python3.11/http/server.py", line 432, in handle
    self.handle_one_request()
  File "/usr/lib/python3.11/http/server.py", line 420, in handle_one_request
    method()
  File "/home/jyung/python/sensors/lib/python3.11/site-packages/vpython-0.0.0-py3.11.egg/vpython/no_notebook.py", line 169, in do_GET
    self.wfile.write(glowcomm.encode('utf-8'))
  File "/usr/lib/python3.11/socketserver.py", line 834, in write
    self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
----------------------------------------
[10107:10142:0110/042532.094024:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.DBus.StartServiceByName: object_path= /org/freedesktop/DBus: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
[10160:10160:0110/042540.391078:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.392871:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.393115:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.393200:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.393314:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.393383:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.393517:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.393601:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.393747:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.393837:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.394026:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.394099:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.394212:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.394270:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.396073:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.396177:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.396273:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.396346:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.396425:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.396477:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.396553:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.396609:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.396687:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.396747:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.396837:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.396907:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10160:0110/042540.397002:ERROR:gbm_wrapper.cc(79)] Failed to get fd for plane.: No such file or directory (2)
[10160:10160:0110/042540.397067:ERROR:gbm_wrapper.cc(262)] Failed to export buffer to dma_buf: No such file or directory (2)
[10160:10262:0110/042540.414990:ERROR:v4l2_utils.cc(584)] Could not open /dev/video10: No such file or directory (2)
[10160:10262:0110/042540.473920:ERROR:v4l2_utils.cc(584)] Could not open /dev/video10: No such file or directory (2)
[10160:10262:0110/042540.507406:ERROR:v4l2_utils.cc(584)] Could not open /dev/video10: No such file or directory (2)


John

unread,
Jan 10, 2025, 12:38:37 AMJan 10
to VPython-users
From the error message it is trying to make a connection on port 38576

Looking up localhost:38567
Making HTTP connection to localhost:38567
Sending HTTP request.

The VPython software looks for an available port to connect to and in your case it chose port 38567. However you can also set an environment variable called VPYTHON_HTTP_PORT on your Raspberry Pi device and specify a port number to use when VPython attempts an HTTP connection. For instance you can set the port number to 4200 in the environment variable with the command:

export VPYTHON_HTTP_PORT=4200

Then it will try to connect on localhost:4200 . You can give this a try to see if it will work for you.

Here is some information about port numbers on a Linux system.

Jeffrey Yung

unread,
Jan 11, 2025, 9:00:46 AMJan 11
to VPython-users
Hi John,

Thanks again. I tried but unfortunately the result is the same, Here is the error message.

Screenshot 2025-01-11 215606a.png

I also run a tcpdump on the loopback interface. It seems after a few back and forth, the server was waiting for 5 hours before client sending stuff, then the process was completed in a few seconds.

Screenshot 2025-01-11 215909b.png

Is there any debug log feature I can turn on in vpython?


Regards,
jY

John

unread,
Jan 11, 2025, 12:42:18 PMJan 11
to VPython-users
Do you have some sort of firewall enabled on your Raspberry Pi 5, if so then maybe that is blocking the connect attempt on port 4200.


If you do have a firewall then try disabling it and see if the connection works or you can also try configure the firewall to allow connections on port 4200.

Another thing you can try is to test that websocket connections are working on your Raspberry Pi. VPython uses the autobahn-python websocket package and you can try running one of their simple websocket demo programs for this python package to make sure that websocket are working. For instance you can try the "echo" demo program here to test that websocket are working.

https://github.com/crossbario/autobahn-python/tree/master/examples/asyncio/websocket/echo

Just download the files onto your Raspberry Pi 5 device and then run the commands in the readme of the above link.

python server.py

client.html

In the client.html webpage click on the button and then open the javascript console to see the test results.

python client.py ws://127.0.0.1:9000

python client_coroutines.py ws://127.0.0.1:9000

In the above test it is using port 9000 so it would be interesting to see if that is being blocked on your Raspberry Pi also.

You can also try running from another computer and use the ip address of your Raspberry Pi device to see if the connection works on port 9000. Assuming your Raspberry Pi has an ip address of 192.168.20.110 then try running from a terminal on another computer. I think the raspberry pi has 2 ip addresses, a device and wi-fi ip address so you can try them both. If you have a firewall then be sure to allow connections on port 9000.

python client ws://192.168.20.110:9000

Another thing to try with jupyter lab is to try connecting remotely to jupyter lab on your Raspberry Pi from a browser on another computer. Just launch jupyter lab on your Raspberry Pi with one of the two ip address's of your Raspberry Pi with the command 

jupyter lab --no-browser --ip="<remote server ip>"

Then you will see a mesage like the following in the terminal

    To access the server, open this file in a browser:
        file:///C:/Users/GuestUser/AppData/Roaming/jupyter/runtime/jpserver-20484-open.html
    Or copy and paste one of these URLs:
        http://192.168.0.20:8888/lab?token=f982953e18fe39ba7a1308ff45a37fc34d685f6f3807b1d2
        http://127.0.0.1:8888/lab?token=f982953e18fe39ba7a1308ff45a37fc34d685f6f3807b1d2
[
Then just copy and past the link into the web browser on another computer.


And check that jupyter lab is working when connected remotely to your Raspberry Pi.


To see debug messages in a jupyter notebook you can check the javascript console for messages. If everything is working OK with vpython in a notebook you should see the following in the javascript console.

START OF GLOWCOMM
glowcommlab.js:1026 END OF GLOWCOMM
glowcommlab.js:101 SANS-SERIF FONT LOADED
glowcommlab.js:112 SERIF FONT LOADED
glowcommlab.js:65 ***WebSocket Connection Opened***

Which operating system are you running on your Raspberry Pi. Did you try installing Ubuntu?

John

unread,
Jan 11, 2025, 1:31:39 PMJan 11
to VPython-users
Also be sure that you are using python version 3 with VPython. Check that you are using python version 3 as your default python.

pi@raspberrypi:~ $ python --version Python 2.7.16 pi@raspberrypi:~ $ python3 --version Python 3.7.3

Tyson Sommer

unread,
Mar 2, 2025, 11:27:03 AMMar 2
to VPython-users
Hi Jeffry,

Did you ever figure this out? I'm having the same problem on a Raspberry Pi 4b I set up a couple weeks ago.

John

unread,
Mar 5, 2025, 5:13:26 PMMar 5
to VPython-users
Hi Tyson

     If Vpython is not working on Raspberry Pi then one important thing to check is if websocket communications is working on your raspberry pi as I mentioned in a previous response. You can check this separately from vpython on your raspberry pi device. Vpython uses the autobahn python package for websocket communication so you can check if the autobahn websocket is working properly by running one of their demo programs. Here are the instructions I provided previously on how to check if its working.


 For instance you can try the "echo" demo program here to test that websocket are working.

Just download the files onto your Raspberry Pi 5 device and then run the commands in the readme of the above link.

python server.py

client.html

In the client.html webpage click on the button and then open the javascript console to see the test results.

python client.py ws://127.0.0.1:9000

python client_coroutines.py ws://127.0.0.1:9000

In the above test it is using port 9000 so it would be interesting to see if that is being blocked on your Raspberry Pi also.

Let us know if the above test works for you so we can rule it out as a reason for vpython not working on Raspberry Pi.

Also if you can't get vpython working on Raspberry pi and you are trying to send data from a sensor or some some other data source on the raspberry pi to a vpython program to visualize something then you can also just run vpython on a PC and then set up a communication channel between the PC and Raspberry Pi and send the data from raspberry to vpython over that channel. See this video on how to set that such a communication channel.

https://www.youtube.com/watch?v=S7Yle8clJ30



John

John

unread,
Mar 6, 2025, 4:11:42 PMMar 6
to VPython-users
Another option is to run Web VPython in a browser on Raspberry Pi device and connect it via websocket to a python program on Raspberry Pi which sends data to webvpython program. You should be able to get this to work with the echo websocket program I mentioned previously.


Just download the server.py demo program to your Raspberry Pi device and ensure that the autobahn python package is also installed on the Raspberry Pi device and launch it with the command.

     python server.py

Then once this server is up and running you can connect to it from a browser on the Raspberry Pi device to a webvpython program like this one.


This webvpython sends the ball position data through the websocket to the echo server running on the Raspberry Pi which in turn sends it back to the webvpython program via the same websocket. You can check the terminal window as well as the javascript console to see the data being sent and received. You should see something like this if you have server.py running on your Raspberry Pi or PC. You can click the linkEdit this program  to view the source code.
 
RPi-webvpython3.jpg

 Note that this webvpython program is the javascript variant with the first line of the program containing the line

JavaScript 3.2

Have a look at the webvpython example programs here which should all run on the web browser on your raspberry pi.


With the javascript version of webvpython you can set up a websocket connection to server.py using javascript code. See


Also look at the client.html file in the autobahn echo server demo for setting up a websocket with javascript.

With these examples you should be able to modify the server.py file to serve up whatever data you want from the Raspberry Pi device to a webvpython program.


John

T.S.

unread,
Mar 7, 2025, 10:27:46 AMMar 7
to vpytho...@googlegroups.com

Hi John. Thank you for your response!

I cloned the Autobahn-python repo and ran the server.py file in the echo websocket example folder. I got a browser window with two buttons for sending a text and binary message. I was able to see the responses in my javascript console.

 

 

 

Also, if it helps, if I launch a Jupyter notebook and do a very simple script in one of its cells, I do get the interactive vpython window.



 

But… running the same script on a command line repl just gets me this:

 

 

And when I ctl-c, I get this:

 

 

And when I ctl-c again, I get this and the repl exits:

 

 

I do want to be able to use the Raspberry Pi as the webserver serving the vpython though so I can view it from any device, so installing vpython on the client devices won’t be an option, unfortunately.

 

 

Tyson

 

I also run a tcpdump on the loopback interface. It seems after a few back and forth, the server was waiting for 5 hours before client sending stuff, then the process was completed in a few seconds.

 

--
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 visit https://groups.google.com/d/msgid/vpython-users/a796d7f9-4343-457b-b0f2-d94f5c0b0085n%40googlegroups.com.

image001.png
image002.png
image003.png
image004.png
image005.png

Jeffrey Yung

unread,
Mar 7, 2025, 11:36:42 AMMar 7
to vpytho...@googlegroups.com
Hi Tyson, unfortunately I don't have any progress.


Regards,
jY

--
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/9EruHyzn9DI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vpython-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vpython-users/db7dbb28-0e06-460c-9b90-ce15f1befd4bn%40googlegroups.com.

John

unread,
Mar 7, 2025, 11:51:49 AMMar 7
to VPython-users
Glad to see that you have vpython working in a jupyter notebook. The reason why your simple script

from vpython import *
sphere()

didn't work from the command line repl is that you need to have a loop and a rate() statement in your program when running from the command line. Try this program from the command line and let us know if it fixes the problem.

from vpython import *
sphere()
while True:       # Needed when running from a terminal
    rate(30)

The vpython demo programs that can be ran from the command line can be found on github here.


You should download some of these vpython demo programs and try running them from the command line on your Raspberry Pi device. For instance to run the Bounce.py demo program from the terminal just type the command.

    python Bounce.py

The corresponding version of these demo programs for jupyter notebook can be found here.


You can also try some of these in a jupyter notebook on your Raspberry Pi.

Also, since you have autobahn websockets working on your Raspberry Pi device, try running the server and then test to see if it works with the webvpython demo program I mentioned previously.

Step 1:  run autobahn server.py file from terminal on Raspberry Pi

          python server.py

Step 2: Using browser on Raspberry Pi, go to this website and see if you get a bouncing ball indicating that the websocket communication is working between echo server demo and webvpython program.


You can check the javascript console as well as the terminal window to see that messages are being sent and received across the websocket. Let us know if this is all working for you on your Raspberry Pi.
 

John

T.S.

unread,
Mar 7, 2025, 3:23:26 PMMar 7
to vpytho...@googlegroups.com

Hi John,

 

I actually tried the script with the rate previously as well to no avail. Just ran it again (not from a repl, but from a test.py file) and still getting the same result. I have to run it from a test.py file because as soon as I enter “sphere()” on the repl, it clears the screen and presents that “waiting for response” message. I can’t type in any more code to enter the while loop with the rate.

 

I did some of those examples from that link before too and all had the same result. That’s when I googled some more and found this google groups thread.

 

I noticed that when I try to run any of the code from the command line and it says “waiting for response,” I don’t see any new services listening in “netstat -l” like I do when I run it from a Jupyter notebook. Should I see a new server listening on any certain port while the app is running from the cli?

T.S.

unread,
Mar 7, 2025, 3:25:17 PMMar 7
to vpytho...@googlegroups.com

Oh sorry to mention that yes, the glowscript test with webvpython also does work. So both Jupyter and webvpython are working, but running from repl or by launching a simple test.py script do not work.

 


Sent: Friday, March 7, 2025 10:52 AM

John

unread,
Mar 7, 2025, 3:52:24 PMMar 7
to VPython-users
Maybe you can try running the vpython program from an IDE like Idle or PyCharm or Spyder or VSCode and see if it works from an IDE running on Raspberry Pi. You can try any of the vpython demo programs in the Demos_no_notebook folder on github.

They use the same mechanism as launching vpython from the command line and running the simulation in a browser window. It would be interesting to know if vpython works from within an IDE on Raspberry Pi.

John

T.S.

unread,
Mar 7, 2025, 4:08:27 PMMar 7
to vpytho...@googlegroups.com

Interesting. I just wrote the four-line script including the rate in the Thonny IDE on my Raspberry Pi and it did, in fact, work when I pressed the “Run” button. The browser launched and displayed the sphere. And if you want to hear something even more interesting, I tried running just the two-line script without the rate directly in the repl shell within the Thonny app and that worked as well. The moment I entered “sphere()”, the browser launched and the sphere appeared. Furthermore, to make it even more confusing, the Thonny repl shell is using the same virtual environment that I’m using when trying to run it from the repl via a Linux terminal.

 

So something about running it directly from the OS’s command line repl isn’t working even in the same virtual environment.

John

unread,
Mar 7, 2025, 4:40:25 PMMar 7
to VPython-users
From the vpython.org page 

https://vpython.org/presentation2018/install.html

it says  :   When running from a terminal, if the program does not end with a loop
containing a rate() statement, you need to add "while True: rate(30)"
to the end of the program. This is not necessary when launching from
environments such as Jupyter notebook, IDLE, or Spyder.

T.S.

unread,
Mar 7, 2025, 4:47:25 PMMar 7
to vpytho...@googlegroups.com

Right, but even when I create a test.py script that includes the rate and run it from the CLI with “python test.py”, I still get the same result.

 

Running this doesn’t work from the Linux terminal. It also just hangs on “HTTP request sent. Waiting for response.”:

image001.png

John

unread,
Mar 7, 2025, 7:53:11 PMMar 7
to VPython-users
Hi Tyson

     I don't have a Raspberry Pi device so I am unable to test it out. What I am able to do is run it on my Windows Subsystem for Linux (WSL2) on my Windows 10 computer. The WSL2 is an Ubuntu virtual machine running Ubuntu 24.04.1 LTS. I also have Anaconda distribution of python 3.12 installed on the Ubuntu machine.

     When I run it from the terminal on the Ubuntu virtual machine, everything works fine. The command

      python  Bounce.py

     entered into the terminal will open up the browser window and run the simulation as expected. Closing the vpython simulation browser tab returns the terminal command line ready for the next command.

     You mentioned that you are running Raspberry Pi 4B but didn't mention which operating system you are using. Maybe you can try it with the Ubuntu operating system on the Raspberry Pi.


      Or maybe you can also try creating a new python virtual environment using python version 3.11 or 3.12 and installing and running vpython from that environment.

    Also as an aside you mentioned " I do want to be able to use the Raspberry Pi as the webserver serving the vpython though so I can view it from any device, so installing vpython on the client devices won’t be an option, unfortunately."

     For this the webvpython option with a websocket might be worth looking into. If your Raspberry Pi has an ip address so that it can be connected to from any device then you can enter that ip address along with a port number when connecting the websocket. Have a look at the first few lines of the demo webvpython program I shared and replace the URL "ws://localhost:9000" with the URL of your Raspberry Pi webserver. Edit this program

// Create a WebSocket object with the server URL
const socket = new WebSocket("ws://localhost:9000");
 
You will be able to add websocket functionality to any of the javascript variants of webvpython and connect it to a websocket server on your Raspberry Pi.


With this option the client devices will only need a browser and won't need to install any software on the device. If the Raspberry Pi is connected to any sensors or any other data source that you want to be able to view with vpython on client device, this can be done by sending the data over the websocket from the Raspberry Pi to the client device.

John

T.S.

unread,
Mar 8, 2025, 1:21:34 AMMar 8
to vpytho...@googlegroups.com

Thank you for the info and for all your time, John.

 

After the most recent tests, I figured it was probably something to do with the OS running on the Pi as well. When I get some time, I’ll play around with things to see if I can get it working. I’ll also explore those other options you mentioned more.

 

If I do end up figuring out what the issue is in code, I’ll be sure to post a solution in case anyone else runs into the same thing.

 

Thank you again!!!

John

unread,
Mar 8, 2025, 8:05:14 AMMar 8
to VPython-users
From the vpython documentation, here is a description of the difference between webvpython and vpython.


You can compare the performance of the vpython demo programs on github 

https://github.com/vpython/vpython-jupyter/tree/master/Demos_no_notebook

when you run them on your Raspberry Pi device against the same webvpython programs which run in the browser on the client device.


As mentioned previously, to connect webvpython to a websocket you will need to use the javascript variant of webvpython.


John

John

unread,
Mar 10, 2025, 10:07:14 PMMar 10
to VPython-users
For your   "Raspberry Pi as the webserver serving the vpython "    requirement have a look at the webvpython instructions for  Share or export this program provided for each of the webvpython demo programs.

https://glowscript.org/#/user/GlowScriptDemos/folder/Examples-JavaScript/program/Bounce/share

When used with a webserver like nginx on Raspberry Pi as shown in this video


You can get a result that looks like this, embedding webvpython in your webpage. This webvpython will run in the client device's browser. You should also be able to set up a websocket between javascript variant of webvpython in client browser and python websocket server running on Raspberry Pi like that demonstrated with the autobahn echo websocket server.

nginx-webvpython.jpg






Jeffrey Yung

unread,
Jun 2, 2025, 1:20:14 AMJun 2
to VPython-users
Hi all, I confirm that it works with Thonny and Pycharm IDE, not Viscal Code though.
Reply all
Reply to author
Forward
0 new messages