Advice on setting up Python/VPython in a student computer lab

296 views
Skip to first unread message

Daniel Schroeder

unread,
Dec 29, 2017, 9:35:25 AM12/29/17
to VPython-users
I need some advice on how to set up Python and VPython in a student computer lab. There are too many choices and as usual I'm bewildered. I've used both Python and VPython sporadically in the past but I am not the "Experienced Python / VPython user" mentioned in the "How to get started" instructions. 

This is for a semester-long course in scientific computing. I figure I'll want to use VPython for the animated graphics and GUI features, but the course will also include data analysis and producing professional-quality plots and a bit of SciPy stuff, so I want to have access to packages and the computer's file system. Therefore I don't see how I could just get by with Glowscript. I'd like to use a single Python environment throughout the course if possible. I'd like to give students instructions on how to set up a compatible environment on their own computers if they wish. I'd also prefer not to invest time and energy in obsolete versions of things.

So this means installing VPython 7, right? And the instructions say that to install that I should start with an installation of Canopy or Anaconda. Any advice on which one I should use?

I've been fooling around with Canopy on my own computer, and at first it didn't know what "pip" means (any more than I did). Now it looks like that might have worked, but when I try running a test program ("from vpython import * \\ box()"), I sure don't see any graphics popping up anywhere.

Anyhow, thanks for any and all help and advice.

Dan

Steve Spicklemire

unread,
Dec 29, 2017, 9:52:57 AM12/29/17
to VPython-users, Steve Spicklemire
Hi Dan,

I think most folks in this situation are using Anaconda, but I understand Canopy should also work.

What does the following produce on your system?

import vpython
vpython.version

Since this is a course on scientific computing, and you plan to use other packages, I would suggest using the “jupyter notebook” interface.

I’ve cooked up some examples that you may find useful here:

<https://github.com/sspickle/sci-comp-notebooks>

You’ll notice a link at the bottom of the page “launch binder”

Project 10, in particular, uses VPython 7 to illustrate a coupled harmonic oscillator.

If you use Anaconda you should get the jupyter notebook option (+ scipy, etc.) with the default install.

In my course I have students submit their project reports as jupyter notebooks (you can find the rubric in the same folder).

I hope that helps!

take care,
-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.

Aaron Titus

unread,
Dec 29, 2017, 10:17:33 AM12/29/17
to vpytho...@googlegroups.com
Hi Dan,

I want to further support the suggestions by Steve Spicklemire.

Here is what I suggest:

1. Install Anaconda



I suggest Python 3.x.


2. After installing Anaconda, install VPython.

- open a terminal

- use conda to install vpython:   conda install -c vpython vpython


That is all you and your students will need to get started. You’ll have all the major packages for scientific computing with Python.


After this, the question is how you and your students want to write and run Python programs. Options are:

1. Write in any text editor. Run from the command line using:

python filename.py

2. Write in a python IDE like Spyder or IDLE and run from the IDE. (I know less about the intricacies of this method.)

3. Write and run in Jupyter Notebook.

This last method has enormous potential, I think, for teaching students to integrate code into a “narrative”. It’s like adding rich documentation to the code. It’s been interesting to me to see how students have used Jupyter for their own research. They spend almost as much time on the rich text (the narrative) as they do on their code because “they want to look back and remind themselves of what they were thinking at the time.”  The rich text is written using markdown (and html if you want) and mathjax (subset of LaTeX) for equation typesetting.

Jupyter is a professional tool that is being used for data science of all types.

Steve’s GitHub repo is a great place to see the value of Jupyter as a teaching tool. However, it’s important for students to realize that most Jupyter users aren’t teachers nor students. They simply use it for their own work.

But Jupyter is another layer of complexity, in many ways. So option 1 might be preferred. Then students will simply write, run, and debug. And they will learn to use a terminal.

Aaron

On Dec 29, 2017, at 9:35 AM, Daniel Schroeder <dschr...@weber.edu> wrote:

Bruce Sherwood

unread,
Dec 29, 2017, 10:35:11 AM12/29/17
to VPython-users
Running from the command line is awkward. It's difficult to stop a VPython program because part of the program is running independently in the browser. Better to run from a launcher such as IDLE or Spyder, or use the Jupyter notebook. (Ideally, it should be possible to modify VPython 7 so that the browser program would be shut down when you kill the Python program.)

Dan, when you got no display, how did you launch the program?

I'll mention that just in the last couple days, to my unpleasant surprise, in my Anaconda installation I can no longer use IDLE to launch a program that uses numpy, which includes vpython, but such programs run in other environments. I even reinstalled Anaconda: same strange result. I was not aware of making any change and had often used IDLE.

Aaron is right that while the Jupyter notebook is a powerful environment, it does add more complexity than one might prefer, and Spyder is significantly more friendly. However, be sure to read the instructions about Spyder at vpython.org.

Bruce

Aaron Titus

unread,
Dec 29, 2017, 10:55:07 AM12/29/17
to vpytho...@googlegroups.com
If one is using the vpython package for visualization in a python program, then it is true that a program running from the command line will persist even after the program ends. (It keeps the connection to the browser open, I think.)  However control-c  will stop the program. This doesn’t feel awkward to me because it’s exactly the same way that one stops Jupyter. Jupyter also must persist because of the connection to the browser. I suppose my familiarity with Jupyter makes this artifact of running a program with VPython seem normal.

I mentioned three options for students to write and run their programs. You’ll find that teachers prefer one of the three options for various reasons depending on the other computing skills they are teaching. If you want students to be comfortable with the command line, then this option might be preferable. If you want them to be comfortable with an IDE, then that option is preferable. If you want them to learn markdown and LaTeX and learn to write a "code-driven narrative” then Jupyter is preferable.

Aaron

Bruce Sherwood

unread,
Dec 29, 2017, 11:04:29 AM12/29/17
to VPython-users
Maybe Windows is different? Ctrl-C in a Windows terminal stops the program but leaves the terminal in a state where no inputs are accepted. I wasn't aware that this isn't a problem on other platforms.

Bruce

Aaron Titus

unread,
Dec 29, 2017, 11:14:53 AM12/29/17
to vpytho...@googlegroups.com
You might have to use ctrl-c twice. (This is also true of Jupyter.)

Can you see if using ctrl-c twice on Windows will exit the program and return the command line?

AT

On Dec 29, 2017, at 11:04 AM, Bruce Sherwood <bruce.s...@gmail.com> wrote:

Maybe Windows is different? Ctrl-C in a Windows terminal stops the program but leaves the terminal in a state where no inputs are accepted. I wasn't aware that this isn't a problem on other platforms.

Bruce


Daniel Schroeder

unread,
Dec 29, 2017, 11:50:34 AM12/29/17
to VPython-users
Thanks for all the quick replies!

I just knew y'all would tell me to go to Jupyter. I'm open to any and all suggestions, but perhaps I should emphasize that I'm looking for the simplest possible solution--both for me and for the students. My knowledge of Python and VPython is at least five years out of date, I've never run either from anything but the command line, and I'm absolutely terrified of Github. I even had trouble getting logged onto Google Groups. I really want to spend more time coding and less time wrestling with all these externalities. (So then why am I even considering Python, you ask? Good question.)

It sounds like nobody is using Canopy and I should abandon it and switch to Anaconda. OK, I'll try that, but meanwhile, in response to some of the questions:

I'm trying to run stuff from the Canopy IDE, if that's what it's called. I'm using a Mac (although the student computers are Windows), and it just says "Canopy" in the menu bar at the top of the screen. The window has an editor pane at the top and a shell pane at the bottom. In the shell the first line is "Welcome to Canopy's interactive data-analysis environment!" (Very friendly!) I've successfully run Python programs that don't use VPython in this environment.

Anyhow, when I use the "Run File" menu command to run my little VPython test program (whether it tries to create a box or just says "vpython.version", all that happens is a line like this gets added to the scrolling text in the shell pane:

In [6]: %run "/var/folders/08/r75t4_n500x1k86xkx1r7bt40000gn/T/tmpZdKlQx.py"

Then it prompts me for "In [7]:". So as far as I can tell, the program produces no visible output and no visible error messages, then exits.

Should I keep wrestling with Canopy or start over and install Anaconda?

Dan

Aaron Titus

unread,
Dec 29, 2017, 11:58:57 AM12/29/17
to vpytho...@googlegroups.com
Yes, definitely use Anaconda. It seems to be the standard python installation for scientific computing in python.

I think the simplest solution is what you are most comfortable with: your favorite text editor and the command line (terminal). 

AT

Daniel Schroeder

unread,
Dec 29, 2017, 12:11:42 PM12/29/17
to VPython-users
Thanks, Aaron.  I take it from your exchange with Bruce that the "awkward" aspect he's referring to is simply that you have to use control-c to stop the program?

Actually, because our student computers run Windows and I'm used to a Mac, there might be some advantage to using an IDE that looks reasonably similar on both.

Dan

Aaron Titus

unread,
Dec 29, 2017, 12:27:54 PM12/29/17
to vpytho...@googlegroups.com

> On Dec 29, 2017, at 12:11 PM, Daniel Schroeder <dschr...@weber.edu> wrote:
>
> Thanks, Aaron. I take it from your exchange with Bruce that the "awkward" aspect he's referring to is simply that you have to use control-c to stop the program?

Yes. Control-c is only necessary if you are using VPython for the visualization. But there’s another small issue on Windows. What is the terminal? I think Anaconda for Windows comes with its own terminal that uses linux syntax for navigating the filesystem, running programs, running conda (Anaconda’s package manager), etc. I’m not sure about that. Maybe other Windows users can comment on their experience with a terminal. This could be another awkward aspect of running programs from a terminal on Windows.

I’ve had 20 non-science majors in a classroom install Anaconda (on both Mac and Windows), find a terminal of some kind, and install VPython, using pip or conda from the command line, with no problems.

>
> Actually, because our student computers run Windows and I'm used to a Mac, there might be some advantage to using an IDE that looks reasonably similar on both.
>

Yes, I agree. Spyder seems to be the most common free IDE for python. It comes with Anaconda. Pycharm is another IDE that some of my students use (as I recall).


Aaron



Kevin Karplus

unread,
Dec 29, 2017, 1:05:50 PM12/29/17
to vpytho...@googlegroups.com
I avoid Windows as much as I can, but a number of my students have Windows laptops, and I've been forced to use Windows machines in some instruction labs.  The command line is available on all Windows machines as cmd.exe , but many students have no idea how to type a command line on either Windows or Macs—even intro programming courses have them doing just point-and-click.

Anaconda does include its own command-line interpreter (Anaconda prompt), but I've never used it.  I don't use IDEs much—I prefer using one editor for all my work, rather than a different idiosyncratic editor for each different programming language or environment.  I'm already irritated enough by the awful editor that Google mail provides (forced on us by the University administrators)—I don't need yet another editor or shell to learn.


Kevin Karplus   kar...@soe.ucsc.edu    http://www.soe.ucsc.edu/~karplus
Professor of Biomolecular Engineering, University of California, Santa Cruz (on sabbatical F2017)
Affiliations for identification only.


--
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-users+unsubscribe@googlegroups.com.

Daniel Schroeder

unread,
Dec 29, 2017, 1:50:53 PM12/29/17
to VPython-users
OK, I'm about to install Anaconda on my Mac, and the GUI installer lists three choices:

Install for all users on this computer [dimmed, so I can't select it]
Install for me only
Install on a specific disk...

What do I do?

Dan
 

Aaron Titus

unread,
Dec 29, 2017, 1:53:21 PM12/29/17
to vpytho...@googlegroups.com
Install for you only.

AT

Bruce Sherwood

unread,
Dec 29, 2017, 2:31:56 PM12/29/17
to VPython-users
Aaron, on Windows with either the standard terminal or the Anaconda terminal, when I press ctrl-C the animation stops, a message is printed in the terminal that there has been a KeyboardInterrupt, but no further input to the terminal has any effect, including a second ctrl-C. I have to kill the terminal and start a new instance in order to be able to run again.

If I remember correctly Anaconda recommends installing "for me only", but I've run okay with either choice (on Windows). 

Mac installers often ask you to choose a disk even when you have only one.

Another comment about Jupyter notebook vs other launchers (terminal, Spyder, etc.) is that if you are building a presentation that includes documentation and commentary as well as executing programs, Jupyter is the only appropriate choice for a Python-based course. If on the other hand you are just writing and running Python programs, the notebook can be overkill, and the notebook program editor is frankly not very good.

Bruce

Aaron Titus

unread,
Dec 29, 2017, 2:34:56 PM12/29/17
to vpytho...@googlegroups.com
Thanks for testing ctrl-c on Windows. That’s helpful to know. The behavior definitely seems to prohibit running vpython programs from the command line on Windows.

AT

Daniel Schroeder

unread,
Dec 29, 2017, 3:06:36 PM12/29/17
to VPython-users
OK, so I've got Anaconda and VPython installed on my Mac, and I've successfully run a test program from the command line in Terminal. It creates a box object in a browser window. As Aaron says, I need to control-C to exit.

I've also launched Spyder but haven't tried running anything from there, in light of the warnings about how the current(?) version doesn't work with VPython.

So now I need to decide on an environment for editing and running programs. I don't think I want to go to Jupyter. For Spyder I guess I'd have to install an older version? Command-line is "awkward". There are probably other IDEs in the Anaconda installation but I haven't tried them. What's the best choice here, given that most of the class will be using Windows but a few of us will probably use Macs?

Bruce Sherwood

unread,
Dec 29, 2017, 4:10:01 PM12/29/17
to VPython-users
Until a few days ago I would have recommended using IDLE, but given the strange problems I encountered this week I now would recommend Spyder. It's a prominent IDE in the Python world and it has many good features. I've updated the Spyder instructions at vpython.org to provide more help on how to use it. (You may need to reload the page to see the updates.)

Bruce

Daniel Schroeder

unread,
Dec 29, 2017, 11:01:54 PM12/29/17
to VPython-users
Thanks, Bruce. I went ahead and downgraded Spyder on my Mac, and that process seemed to go smoothly. I encountered some glitches when trying to follow these instructions:

You can start Spyder by clicking the Spyder icon that is installed with Anaconda, or you can start Spyder from a command prompt by typing "spyder". In Spyder you must go to Run > Configure and specify "Execute in a new dedicated Python console".


I don't see a Spyder icon anywhere. But there is an Anaconda-Navigator app that lets me launch Spyder, and I can also launch it from Terminal. When I tried to go to Run > Configure, an error message appeared in the Internal Console window. However, I found that setting in Preferences under the application menu.

I also had some trouble getting VPython to work. Looks like if I use the Run command when the IPython console is selected, I get no graphics output (kinda like what happened in Canopy, come to think of it, where I was also looking at an IPython console). But if I use a plain old Python console, it seems to work, opening a new browser tab and putting the graphics there.

I'm having trouble exiting a program and running it again. Seems that I have to close the Python console tab, then go to the menu and create a new Python console. Then I get a new browser tab as well. This is very confusing and I'd appreciate any further advice on how to conveniently launch, exit, and relaunch from Spyder.

Dan

John

unread,
Dec 30, 2017, 1:04:43 AM12/30/17
to VPython-users
You can try a python IDE called thonny which intended for beginner python users.

www.thonny.org

It works with vpython. From the thonny IDE tools menu you can select "manage packages" to install third party python packages such as vpython and other python packages that you may need.

You can google thonny to find out more and there are also some thonny tutorials on YouTube.

John

Reply all
Reply to author
Forward
0 new messages