no video output in jupyter-lab

324 views
Skip to first unread message

Johan Antonissen

unread,
Aug 17, 2022, 4:06:57 AM8/17/22
to VPython-users
Hello there,

I thought I got my vpython script fully working but apparently there is still something wrong.

For context:
What I would like to do is to have this program run on a self hosted binder so that i can put the renderings on vpython in an iframe on a website. I've seen that in order to be able to put the rendering in an iframe on my website i need to run the file in jupyter environment rather than from command line.

The general idea of my platform is that users can design a cupboard on my website, pay me a small ammount of money and then my server generates a assembly manual using main2.py and emails it to the user.

My goal for this app is to self host everything. The goal of this project is not to earn money, its just to learn how I can develop a program and run it on a website. I would like to learn how to do the complete app development from A to Z. Just for fun.

I've made the following program to create a cupboard: https://github.com/deWasbeer/hout-topologie

When I run main.py in spyder this program works perfectly.
When I however run the main.pyinb in jupyter-lab (or jupyter-notebook) I get no rendering, I do see the print statements my program is running so i know it is working.
Sometimes when I stop the program I see a image of what the output should be, but it is static rather than the dynamic input field I am looking for.

I have installed the vpython extention for jupyter notebook, I know it works because when u try to create a box (form vpython import box, box()) i do get an output.

Does anyone have an idea what is going wrong here ?

Thank you very much in advance.

Sorry for all the spam I'm puttig on the forum. I'm trying my best to self learn as much as possible but my background is not IT, it's engineering. So sometimes I do have a lack of knowledge from what is going on.

Thanks again.

Kind regards,

Johan


Steve Spicklemire

unread,
Aug 17, 2022, 7:12:28 AM8/17/22
to vpytho...@googlegroups.com, Steve Spicklemire
It appears your program is making assumptions about the path(s)/filesystem on the computer:

akedirs
mkdir(name, mode)
OSError: [Errno 45] Operation not supported: '/home/windhoos'

Is this something that each user is intended to change?
> --
> 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/60dcd946-ec98-427e-bd51-c380b1d7e4c1n%40googlegroups.com.

Johan Antonissen

unread,
Aug 17, 2022, 7:32:45 AM8/17/22
to VPython-users
Hi there, thank you for the reply.
When i deploy the code in the server a new folder in the working directory. with info should be created for everyone that makes a cupboard.
So actually it should just say ~ rather then /home/windhoos
Let me see how i can change that, sorry for that.

Johan Antonissen

unread,
Aug 17, 2022, 7:54:45 AM8/17/22
to VPython-users
Okay i updated the repo, it should work now: https://github.com/deWasbeer/hout-topologie
I´ve also made a video that shows whats happening on my system: https://youtu.be/748wJNRv4h0

Johan Antonissen

unread,
Aug 17, 2022, 4:24:20 PM8/17/22
to VPython-users
Just created a Debian 11 image with virtual box 
Installed vpython and jupyter-vpython in conda.
Ran the script in Spyder and it worked.
When I ran the script in jupyter I again did not get any output.

So I guess the error should be in my code somewhere, i think it's not in the installation of jupyter of vpython that's the problem.

John

unread,
Aug 17, 2022, 8:23:39 PM8/17/22
to VPython-users
Try running one of the vpython demo notebooks on your jupyter vpython installation to see if they work on your system. The demo vpython notebooks can be found here.


I also forked your repository and added postBuild file and binder/requirements.txt file and a few demo vpython program files so that it can run on mybinder.org. I also added the file maintest.ipynb where I just added a small vpython program in the first cell of the notebook.


If you click on the above link you can try running the vpython demo programs in mybinder.org and see that they work. Then try running your program main.ipynb, also try maintest.ipynb on mybinder to see if you can get it to work on there.

The forked repository is here so you can see the files  I added to it.


John

Johan Antonissen

unread,
Aug 18, 2022, 3:40:32 AM8/18/22
to VPython-users
Hi there,

Thank you for tge reply! greatly appreciated!

I've already included a requirements.txt file and tried it on binder, unfortunatley the same result :( I also tried to just plot a box in my script and that just worked (like it also works in yours).

To be sure I also tried your fork but I got the same result, unfortunatley :(

weird thing is that even tough the program is running, i'm getting no errors and there is also hardly any load on my CPU, which should be the case.

Johan Antonissen

unread,
Aug 19, 2022, 2:10:00 AM8/19/22
to VPython-users
Hello there dear vpython users.

I appologise for asking this, i know you are all very buisy people. My intention is not to be rude!

If anyone has the time to be able to look at what might be going wring i would be very thankful.

I've also added a binder link on my github for easy access to the code.

Thank you in advance.

And again i appologise if i come across as pushy, that is truely not my intention.

John

unread,
Aug 19, 2022, 9:53:36 AM8/19/22
to VPython-users
I think the fact that you are using an IFrame with vpython hasn't been tried before. Try googling "Jupyter Notebook IFrame" and explore what is possible with IFrame's and Jupyter Notebooks. You may get some hits like this one


Also try display an iframe for any generic website and see what works and what doesn't. Sometimes you may get a blank screen. For me running the following code with the magic  %%html in a notebook cell on mybinder displayed a blank cell

%%html
<iframe width="700" height="500" src="http://www.cnn.com"  frameborder="0"allowfullscreen></iframe>

you can also display an iframe in a notebook cell with the command

from IPython.display import IFrame 
IFrame('http://stackoverflow.org', width=700, height=350)

John

Johan Antonissen

unread,
Aug 22, 2022, 1:34:32 PM8/22/22
to VPython-users
Hi there,

Thank you for the reply! Greatly appreciated!

I do think I have found a workflow, I would like to be able to run my code in jupyter-notebook using mybinder which I want to run on my personal server using kubernetes and helm.
If I manage to deploy this in jupyternotebook I think I can use voila to convert my code to a webapp.

My problem now is only that even tough my code works when I run it from spyder, it does not work when I start the code in a jupyternotebook.
I'm able to get the code running and see the first output. But I'm not able to render the 3D model since for some reason buttons don't work, or at least there is a problem somewhere between the inputting of the data in the datafield and the rendering of the 3D model.

Problem is, I'm getting no error logs .....

One weird thing also is that my code also does not run on mybinder.... And I have no clue why....


kind regards,

Johan

John

unread,
Aug 22, 2022, 4:42:35 PM8/22/22
to VPython-users
Hi  there appears to be a bug with vpython widgets in the jupyter notebook with the latest vpython release. Try using the previous release of vpython and jupyterlab-vpython in your requirements.txt file by specifying  the release version.
    
vpython==7.6.3
jupyterlab-vpython==3.1.3

With regards to voila, vpython hasn't been tested with voila so there is no guarantee that it will work.

John

John

unread,
Aug 23, 2022, 7:54:27 AM8/23/22
to VPython-users
WIth regard to the issue of buttons not working I tried running 3 vpython demo programs that test buttons and widgets on your mybinder link


and 2 of the 3  ran OK. Here are the 3 notebooks I tested that contain buttons and widgets.


The 1st and 3rd in this list worked OK on your mybinder link but the 2nd one the buttons were unresponsive. The 1st and 2nd one use ipywidgets and have the line

import ipywidgets as wd

If you are using ipywidgets then you might need to do something like the async version in the 1st file and add some async code to get the buttons to be responsive in a jupyter notebook. It contains python async code around the while True:  loop in vpython

while True:
    rate(100)
    if running:
        currentobject.rotate(angle=1e-4*sl.value, axis=vec(0,1,0))

with async code becomes

import asyncio
async def periodic():
    while True:
        await asyncio.sleep(0)
        rate(100)
        if running:
            currentobject.rotate(angle=1e-4*sl.value, axis=vec(0,1,0))

loop = asyncio.get_event_loop()
task = loop.create_task(periodic())

The 3rd file uses buttons and widgets that are build into the vpython package and worked OK on your mybinder link.

Johan Antonissen

unread,
Aug 23, 2022, 11:08:09 AM8/23/22
to VPython-users
Dear john,

Thank you for all this! This feedback will keep me buisy for quire some time :)

I started to learn C++ to overcome my problems but your comment is a huge point of light in the tunnel :)

Johan Antonissen

unread,
Aug 26, 2022, 4:08:55 AM8/26/22
to VPython-users
Okay i made some progress.

I've found out that my program halts art the winput statement.

I've set a print statement before and after the line of code, and only the first line is printed in the console in jupyter!

    print('pre-winput')
    kast_width=winput( bind=input_raam , width=56, pos=scene.title_anchor, id=1)
    print('post-winput')

This line is located in the onderdelen/plotter.py  in function 'build scene' line 226.
I've checked if the function I'm calling with winput is called using a print statement (line 17) but it is not triggered.

I am using the vpython and extension versions as suggested by john (as can be seen in environments.yml).

Could this be a undiscovered bug in vpython ?

John

unread,
Aug 26, 2022, 11:37:11 AM8/26/22
to VPython-users
winput works for me on your mybinder link you have in

https://github.com/deWasbeer/hout-topologie

Try the following code in a notebook cell on your mybinder site. If you type a number in winput then it will print that number out twice from the print statement in the bound function T(s).

from vpython import *

box()

def T(s):
    print(s.text, s.number)

scene.caption = 'This is a test'
winput( bind=T )
w = wtext(text=' afterthought')

John

John

unread,
Aug 26, 2022, 12:01:49 PM8/26/22
to VPython-users
You could also try the following program in a notebook cell on your mybinder website. Note that I have added a "scene = canvas()" statement. This is necessary if you want to execute the notebook cell more than once and have the vpython 3D scene displayed. If this statement is missing then you won't see anything displayed in the output cell in a notebook when you execute the cell a second time. The following code will redisplay the scene each time you execute the notebook cell.

from vpython import *
scene = canvas()


box()

def T(s):
    print(s.text, s.number)

scene.caption = 'This is a test'
W = winput( bind=T )
W.text = "42"

w = wtext(text=' afterthought')

Reply all
Reply to author
Forward
0 new messages