import problems

166 views
Skip to first unread message

Mikhail Moldovan

unread,
Jul 30, 2016, 7:10:05 AM7/30/16
to VPython-users
I am trying to run:

from vpython import *

But I get:

Traceback (most recent call last):

  File "star_scr.py", line 1, in <module>

    from vpython import *

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vpython/__init__.py", line 10, in <module>

    from .vpython import *

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vpython/vpython.py", line 417, in <module>

    get_ipython().kernel.comm_manager.register_target('glow', GlowWidget)

AttributeError: 'NoneType' object has no attribute 'kernel'

Exception in thread Thread-1:

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner

    self.run()

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 1082, in run

    self.function(*self.args, **self.kwargs)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vpython/vpython.py", line 384, in commsend

    next_call = next_call+rate.interactionPeriod

AttributeError: 'NoneType' object has no attribute 'interactionPeriod'

Steve Spicklemire

unread,
Jul 30, 2016, 9:50:07 AM7/30/16
to vpytho...@googlegroups.com, Steve Spicklemire
Hi Mikhail,

You are running this in an jupyter notebook, or the command line?

vpython is designed to be run only within a jupyter notebook environment.

-steve
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

Jp Hadden

unread,
Apr 7, 2017, 8:30:20 PM4/7/17
to VPython-users, stevespi...@gmail.com
Hi,

I guess I have run into this problem as well.  Does this mean it is impossible to import the various functionality into non-jupyter applications?  A bit of a pity - I have quite a bit of code that uses 'visual' etc.  There is no way to import whatever libraries are used here into a bog standard python script?

Bruce Sherwood

unread,
Apr 7, 2017, 8:39:25 PM4/7/17
to VPython-users, Steve Spicklemire
Correct. Jupyter VPython (as the name implies) must run in a Jupyter notebook, as the 3D graphics is rendered by the WebGL graphics library that is built into browsers. But a Jupyter notebook Python program that imports vpython can also import any other Python module.

Jp Hadden

unread,
Apr 7, 2017, 9:21:24 PM4/7/17
to vpytho...@googlegroups.com, Steve Spicklemire
Fair enough.  I guess I'll take a look at Jupyter at some point then.  Still, a part of me likes the idea that code can work independent of the development tool.  But thanks for your help.



On Fri, Apr 7, 2017 at 6:39 PM, Bruce Sherwood <bruce.s...@gmail.com> wrote:
Correct. Jupyter VPython (as the name implies) must run in a Jupyter notebook, as the 3D graphics is rendered by the WebGL graphics library that is built into browsers. But a Jupyter notebook Python program that imports vpython can also import any other Python module.

--
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/AIqkaSFdGaQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vpython-users+unsubscribe@googlegroups.com.

Aaron Titus

unread,
Apr 8, 2017, 3:56:29 PM4/8/17
to vpytho...@googlegroups.com
VPython and Plotly (a package for graphing data) are similar in that both require a web browser for displaying their output, which is a scene in VPython and a graph in Plotly. Plotly draws its graph with HTML and JavaScript because this provides many interactive features that matplotlib does not. Thus, there are other reasons, besides VPython, to use a browser to run your Python programs.

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.

Bruce Sherwood

unread,
Apr 8, 2017, 4:13:10 PM4/8/17
to VPython-users
In principle it ought to be possible to write a VPython program, containing "import vpython", and run it from a terminal or from idle or whatever Python editing environment you want, but this fails with a Jupyter error. The vpython module needs to invoke the Jupyter notebook machinery because it needs to send instructions to a JavaScript program running in a browser which calls the GlowScript library to use WebGL to render the 3D scene. 

Maybe it's a failing of the Jupyter notebook machinery that you have to start in a Jupyter notebook in order to use the Jupyter notebook machinery, but that's the current situation. I don't know a way around this. It would be nice if someone would create a mechanism to start a notebook from within an ordinary Python program, but I don't know nearly enough to be able to judge whether such a thing would be possible.

Reply all
Reply to author
Forward
0 new messages