Using VPython without Jupyter

593 views
Skip to first unread message

Joseph Glaser

unread,
Sep 21, 2016, 5:37:41 PM9/21/16
to VPython-users
Hello All,

My name is Joe Glaser, a graduate student at Drexel University. We recently upgraded some of our systems from Ubuntu 12 LTS to Ubuntu 14 LTS. This seems to have caused some problems with our python 2.7.6 installs. After installing vpython (1.0.8) and its dependencies via pip (8.1.2), we do the following via a bash shell terminal:

$ python -c "import visual"
Traceback (most recent call last):
 
File "<string>", line 1, in <module>
 
File "/usr/local/lib/python2.7/dist-packages/visual/__init__.py", line 1, in <module>
   
from .visual_all import *
 
File "/usr/local/lib/python2.7/dist-packages/visual/visual_all.py", line 1, in <module>
   
from vis import version
 
File "/usr/local/lib/python2.7/dist-packages/vis/__init__.py", line 3, in <module>
   
from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
ImportError: libboost_python-py27.so.1.46.1: cannot open shared object file: No such file or directory


This is rather odd as the machines in question only have the following .so's installed:
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.54.0

Currently, libboost-python1.46.1 is not installable on Ubuntu 14 LTS as it was replaced by 1.54.0 due to several issues.

In an attempt to remedy this problem, we tried a local install of Anaconda and used conda to install vpython through the suggested command. This worked well, but only when running VPython within a Jupyter window.

Since we use VPython as an instruction method for basic programming in physics during our Freshman courses, we would rather be able to continue to write code for VPython in gedit and run the .py files via the command line. Is this even still possible? If so, are there any suggestions on dealing with the libboost error?

Thanks very much for your help!

Warm Regards,
Joseph Glaser


Robert A. Knop Jr.

unread,
Sep 21, 2016, 5:49:59 PM9/21/16
to vpytho...@googlegroups.com
On Wed, Sep 21, 2016 at 02:37:40PM -0700, Joseph Glaser wrote:
> My name is Joe Glaser, a graduate student at Drexel University. We recently
> upgraded some of our systems from Ubuntu 12 LTS to Ubuntu 14 LTS. This
> seems to have caused some problems with our python 2.7.6 installs. After
> installing vpython (1.0.8) and its dependencies via pip (8.1.2), we do the
> following via a bash shell terminal:

(Aside: who do you work with there?)

I have succesfully used VPython on both Ubuntu 14.04. However, I
compiled it myself. I also had to download and compile wxPython, as the
one that came with Ubuntu 14.04 wasn't new enough. I also made a few
small changes to setup.py and visual_common/create_display.py, but those
were to work around problems with Intel display chips that may or may
not be relevant to you. (I can send you the diffs if you're
interested.)

Did you compile everything yourself, or did you use a binary install of
vpython? Have you recompiled after updating to Ubutu 14?

> Since we use VPython as an instruction method for basic programming in
> physics during our Freshman courses, we would rather be able to continue to
> write code for VPython in gedit and run the .py files via the command
> line.

I hear ya on this. I'm sad that vpython has gone from being a library
that works with standard Python to something that only runs on top of
another environment. While it may be faster and easier for people to
get started with it, it doesn't integrate well if you want students to
go on and do more things later using standard Python stuff, and not
tying yourself specifically to the Jupityr environment.

However, the last version of VPython before the Jupityr switch does stil
seem to work. (I guess I still need to make it work in Ubuntu 16.04;
I'll let you know how that goes.)

-Rob

--
--Rob Knop
E-mail: rk...@pobox.com
Home Page: http://www.pobox.com/~rknop/
Blog: http://www.galacticinteractions.org/
signature.asc

Bruce Sherwood

unread,
Sep 21, 2016, 6:23:31 PM9/21/16
to VPython-users
There seems to be some confusion here. Joseph, you installed "pip install vpython" which installs the Jupyter notebook version of VPython, version 1.0.8. Instructions for use of this version are found on the first page of vpython.org. The statement "import visual" fails because the name of the Jupyter VPython module is "vpython", and one has to start from a Jupyter notebook, not from a terminal.

Rob describes building Classic VPython from source. The relevant repository is https://github.com/BruceSherwood/vpython-wx, and the file INSTALL.txt provides information on how to build for Linux. It's not easy, but it's possible, and "import visual" will work.

We VPython developers regret not being able to support Classic VPython any longer, but it became nearly impossible. Here is an article on why we had to make this change, and what is gained by the change:


Robert A. Knop Jr.

unread,
Sep 21, 2016, 8:05:36 PM9/21/16
to vpytho...@googlegroups.com
On Wed, Sep 21, 2016 at 04:23:30PM -0600, Bruce Sherwood wrote:
> Rob describes building Classic VPython from source. The relevant repository
> is https://github.com/BruceSherwood/vpython-wx, and the file INSTALL.txt
> provides information on how to build for Linux. It's not easy, but it's
> possible, and "import visual" will work.

I just did it under Ubuntu 16.04. The vpython git repository works
as-is there; no patches or changes needed. Under Ubuntu 14.04, I had to
download a newer version of wxpython than was in Ubuntu, but with 16.04
the one that comes with Ubuntu seems to work. So, doing it on Ubuntu
16.04 is actually not very painful at all.

Once you've cloned the git archive, all you have to do is cd into the
vpython-wx directory and run

python setup.py build

Then, when it dies complaining that something isn't there, apt-get
install it, and repeat, until the build makes it all the way through.
(By reading INSTALL.txt, you can probably figure out what to apt-get
install before even starting the build, but, well, I was lazy.)
Everything you need is in Ubuntu. Eventally it builds. Then just

sudo python setup.py install

which will install it in the default place (under /usr/local). If you
want it to go somewhere else, add "--prefix=/opt" or whatever at the
end. (On a bunch of my machines, I had to make the NFS shared directory
/opt rather than /usr/local. It was Nvidia's fault; they distributed
Cuda in .debs that installed to /usr/local rather than /usr, which you
aren't supposed to do. The result was that things got messy if
/usr/local was an NFS shared directory.)
signature.asc

Robert A. Knop Jr.

unread,
Sep 21, 2016, 8:08:07 PM9/21/16
to vpytho...@googlegroups.com
On Wed, Sep 21, 2016 at 04:23:30PM -0600, Bruce Sherwood wrote:
> We VPython developers regret not being able to support Classic VPython any
> longer, but it became nearly impossible. Here is an article on why we had
> to make this change, and what is gained by the change:
>
> http://vpython.org/contents/announcements/evolution.html

Is it really true that classic VPython only used CPU-based OpenGL?
Interesting; I'd always thought it was using some of the GPU accelerated
3d.
signature.asc

Bruce Sherwood

unread,
Sep 21, 2016, 9:21:43 PM9/21/16
to VPython-users
Classic VPython made a minor use of the GPU, only for materials (textures). 

Among the limitations of this CPU-based rendering is that it's easy in Classic VPython to see mistakes in the handling of opacity, because objects are ordered back to front by their centers, whereas the GlowScript library used in GlowScript VPython and Jupyter VPython uses a "depth-peeling" algorithm to handle opacity correctly at the pixel level, exploiting the GPU. In the following example, notice how the two long intersecting transparent boxes are rendered correctly:


This situation is rendered incorrectly in Classic VPython.

Bruce Sherwood

unread,
Sep 22, 2016, 10:41:43 AM9/22/16
to VPython-users
Joseph, you said, "Since we use VPython as an instruction method for basic programming in physics during our Freshman courses..." At the intro level, where students are presumably writing relatively simple programs that don't require such things as the numpy module, have you considered using GlowScript VPython? When it became available a year ago, some institutions using Matter & Interactions and VPython (for example, Georgia Tech) switched to GlowScript VPython and experienced a remarkable increase in student enthusiasm for VPython. This is probably due to avoiding the difficulties of installing Python, installing VPython, and on a Mac installing an update to Tcl, and to not needing to know anything about folders, files, and file extensions; they could just concentrate on the physic. You avoid the installation issues by providing VPython on university computers, but presumably students also use VPython on their own computers, so the issue may remain.

Joseph Glaser

unread,
Sep 22, 2016, 3:53:34 PM9/22/16
to VPython-users
Hello All,

Thanks for your many replies over the past several hours. It is great to see a community of users this active. :D

@Rob: I'm the new System Administrator for the department so I am currently working alongside Dr. Goldberg for this issue. I preform my computational astrophysics research under Dr. McMillan. Thanks for the notes on installation of Classic VPython from source. This cleared up a lot of confusion because it seemed like the Linux install of the old software was through Wine, which would have been quite odd.

I have installed the package successfully via the following commands on a local install of Anaconda 64-Bit:
$ git clone https://github.com/BruceSherwood/vpython-wx.git
$ cd vpython
-wx
$ conda install wxPython
$ python setup
.py build
$ python setup
.py install

However, running the following command produces a dependency issue:
$ python -c "import visual"
The Polygon module is not installed,
   so the text
and extrusion objects are unavailable.
The ttfquery and/or FontTools modules are not installed,
   so the text
object is unavailable.

Trying to install the missing packages via conda or pip seems to not work as they can't find a suitable Linux version of either program. Any suggestions on this front?

@Bruce, Thank you for your comments regarding VPython's direction. I enjoy the ability to use it in the Jupyter environment as that is how I prefer to program my code. However, since this course series is built as a bootcamp into programming with the goal of preparing students for their first research co-op, it is necessary to start with the basics in terminal/gedit. This class is meant to also allow the students to have a more direct connection between the physics they learn in their classes and the language that they will use in many of their classes.

Warm Regards,
Joseph Glaser

Bruce Sherwood

unread,
Sep 22, 2016, 4:24:37 PM9/22/16
to VPython-users
Here is what the repository file INSTALL.py says about Polygon, ttfquery, and FontTools:

You'll need Python modules Polygon, FontTools, and ttfquery, from pypi.python.org.
The setup.py script will attempt to build/install these if they are not
present, but sometimes it can't find them. If that happens, download the
source for each module, unpack and in a terminal cd to the module folder.
Execute "sudo python2.7 setup.py install" to build and install the module.

However, it is highly unlikely that your students will use the extrusion or (3D) text objects, so you can choose to not install these modules. If the error message is too annoying, you could create dummy modules so that the message wouldn't appear. Here is what the text and extrusion objects look like:



The reason for the instruction on using Wine is that over the years many Linux users were unable to fight their way through building from source. This was especially true if the user's Linux was some obscure flavor.

Robert A. Knop Jr.

unread,
Sep 22, 2016, 4:27:26 PM9/22/16
to vpytho...@googlegroups.com
On Thu, Sep 22, 2016 at 12:53:33PM -0700, Joseph Glaser wrote:
> I preform my computational astrophysics research under Dr. McMillan.

Ah, OK. I just saw Steve a few weeks ago at the MODEST conference in
NYC.

> However, running the following command produces a dependency issue:
> $ python -c "import visual"
> The Polygon module is not installed,
> so the text and extrusion objects are unavailable.
> The ttfquery and/or FontTools modules are not installed,
> so the text object is unavailable.

I have to be honest -- I've always ignored this and just not used the
text and extrusion objects....

-Rob
signature.asc

Joseph Glaser

unread,
Sep 23, 2016, 3:18:14 PM9/23/16
to VPython-users
Hey all,

Thanks again for all this support. So, installing Classic VPython 6.11 from source was very painless as described above on the default python (2.7.6) that comes with Ubuntu 14 LTS. Somehow I have the above mentioned packages installed still on them which is odd.

However, using 6.11 is causing some issues as the window does not render in real-time (for example running "$ python" and manually coding things in terminal), only when the script has completed its run. I know this is a minor issue, but I am being told that it is a necessity.

As such, I uninstalled 6.11 and installed 5.74 from source via the tar.bz linked on the website. To do so, I ran the following the the vpython source directory:

$ which python
$ which pip
#This returns the default python directory and site-package path that configure finds.
$
./configure
# Whole bunch of yes results.
$ make
$ sudo make install

Running a simple python command after the install (which seems to go fine) results in:

$ python -c "import visual; print visual.version;"

Traceback (most recent call last):
 
File "<string>", line 1, in <module>
 
File "/usr/local/lib/python2.7/dist-packages/visual/__init__.py", line 1, in <module>
   
from .visual_all import *
 
File "/usr/local/lib/python2.7/dist-packages/visual/visual_all.py", line 1, in <module>
   
from vis import version
 
File "/usr/local/lib/python2.7/dist-packages/vis/__init__.py", line 3, in <module>
   
from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
ImportError: libboost_python-py27.so.1.46.1: cannot open shared object file: No such file or directory

Any suggestions regarding this front?

~ Joe G.

Reply all
Reply to author
Forward
0 new messages