Does VPython support Python3?

2,292 views
Skip to first unread message

Aleksejs Fomins

unread,
Oct 24, 2016, 10:31:55 AM10/24/16
to VPython-users
Dear All,

I am completely new to VPython. I have managed to install VPython for python 2.7 on my Ubuntu 16.10 machine using the command

sudo apt-get install python-visual

and run a few cool examples. It works, but has two problems
1) It appears to be significantly outdated, to the extent where tutorial commands like myface.make_twosided() are not recognised.
2) I am using Python 3.5 for my large simulation code, and I would like to make a VPython visualization to be part of that code, thus using Python 3.5

I would prefer to avoid using anaconda etc. I don't quite understand how it works, especially on how to install an anaconda module that is not part of anaconda, and how to resolve any following conflicts.

So far I have tried installing via

sudo pip3 install vpython

However, when I call

>>> from visual import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'visual'

>>> from vpython import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/vpython/__init__.py", line 10, in <module>
    from .vpython import *
  File "/usr/local/lib/python3.5/dist-packages/vpython/vpython.py", line 442, in <module>
    get_ipython().kernel.comm_manager.register_target('glow', GlowWidget)
AttributeError: 'NoneType' object has no attribute 'kernel'


Would you be so kind to explain to me how to solve this problem?
If the way I have installed VPython is not correct, please suggest how to do so. I will not have the need for browser-based visualization, just plain simple console.

Best regards,
Aleksejs Fomins
PhD student of Nanophotonics and Metrology Lab,
EPFL, Switzerland

Bruce Sherwood

unread,
Oct 24, 2016, 11:32:08 AM10/24/16
to VPython-users
The brief answer is no. Here is a less brief answer.

I don't know what version of VPython is installed by sudo apt-get install python-visual, but I suspect it is older than Classic VPython 6, since you found that make_twosided() isn't recognized. You should be able to determine the version by executing "print version".

The most recent (and final) version of Classic VPython is version 6, which depends on wxPython, which at the time of ending the further development of Classic VPython did not have a Python 3 release. You could attempt to build Classic VPython for Python 3 from source (including the pre-alpha version of wxPython that is now available at wxpython.org).

pip works as expected in the Anaconda environment; the fact that there also exist Anaconda-specific installer options doesn't prevent pip from working, and Anaconda supports Python 3. If you have your own modules to import, either put them in site-packages or in the same folder as your own Jupyter notebooks. Short of building Classic VPython from source, I do not know of any way to use VPython with Python 3 other than by using Jupyter VPython.

If you have not already read it, please do read http://vpython.org/contents/announcements/evolution.html for why it was necessary for us developers to abandon Classic VPython.

Bruce Sherwood

unread,
Oct 24, 2016, 1:56:47 PM10/24/16
to VPython-users
I should add that Jupyter VPython will not run from the command line. As the name Jupyter implies, Jupyter VPython must be run in a Jupyter notebook, because both Jupyter VPython and GlowScript VPython use the WebGL 3D graphics library that is built into modern browsers.

Aleksejs Fomins

unread,
Oct 25, 2016, 9:48:11 AM10/25/16
to VPython-users
Dear Bruce,

Thank you very much for your reply.
After about two weeks of search through resources like VPython, Mayavi and PythonOCC I am unable to find the tool that
1) Works with python3
2) Runs from console
3) Plots non-uniform 3D meshes
I suppose I'll just have to write my own mesh visualization tool based on matlibplot :D

Bruce Sherwood

unread,
Oct 25, 2016, 10:55:26 AM10/25/16
to VPython-users
Regarding point 3, Jupyter VPython (and GlowScript VPython) have "vertex" objects whose attributes include pos, normal, color, and there are "triangle" and "quad" objects that are built from these objects, so one can plot non-uniform 3D meshes. Moreover, one can make a "compound" object, which stores the mesh in GPU memory, thereby making possible very rapid display. At


see the programs "Plot 3D function" and "Rug" as dynamic mesh examples. You can also see these same programs at glowscript.org by choosing "Example programs".

So the only thing you're missing in the VPython world is "Runs from console", which seems somewhat ironic, as the IPython (now Jupyter) environment was, as I understand it, created to provide an unusually powerful console capability. Presumably if "runs from console" simply means that this is how you want to start a program, perhaps it is possible to write a simple shell script that runs "jupyter notebook" with arguments to choose the program to run. You might wish to ask about such options on the Jupyter forum at


Jiri Kral

unread,
Feb 3, 2017, 3:41:35 PM2/3/17
to VPython-users
Hi Bruce,
You must have answered this million times - sorry. Is there a plan for visual to fully support Python 3 in the future?
I just converted most of my codes to Python 3 and going back to 2.7 is... sigh... :-)
Thank you!
PS I am amazed by Visual Python  - I wish I came across it much sooner. What a great tool for schools and such.


Bruce Sherwood

unread,
Feb 3, 2017, 4:04:47 PM2/3/17
to VPython-users
Yes, Jupyter VPython has always run on Python 3. It's only Classic VPython that doesn't. See the first page of vpython.org.

Kevin Karplus

unread,
Feb 3, 2017, 4:37:45 PM2/3/17
to vpytho...@googlegroups.com

On Fri, Feb 3, 2017 at 12:41 PM, Jiri Kral <jiri...@gmail.com> wrote:
You must have answered this million times - sorry. Is there a plan for visual to fully support Python 3 in the future?
I just converted most of my codes to Python 3 and going back to 2.7 is... sigh... :-)

​I hope that Vpython always supports Python 2.7  There is a lot to be said for having a frozen language that does not change out from under you.
(Most of my research code written over the past 30 years is now useless, because C++ has changed too much, while the papers written with TeX are still compilable.)​


Kevin Karplus   kar...@soe.ucsc.edu    http://www.soe.ucsc.edu/~karplus
Professor of Biomolecular Engineering, University of California, Santa Cruz
Undergraduate Director, Bioinformatics
Program Chair and Undergraduate Director, Bioengineering
Affiliations for identification only.

Bruce Sherwood

unread,
Feb 3, 2017, 5:12:15 PM2/3/17
to VPython-users
I didn't mean to imply that Jupyter VPython doesn't run with Python 2.7: it does run with either Python 2.7 or Python 3.2.

Reply all
Reply to author
Forward
0 new messages