Skip to main content

VPython for Jupyter Notebook

Project description

VPython

This package enables one to run VPython in a browser, using the GlowScript VPython API, documented in the Help at https://www.glowscript.org. If the code is in a cell in a Jupyter notebook, the 3D scene appears in the Jupyter notebook. If the code is launched outside a notebook (e.g. from the command line), a browser window will open displaying the scene.

VPython makes it unusually easy to create navigable real-time 3D animations. The one-line program "sphere()" produces a 3D sphere with appropriate lighting and with the camera positioned so that the scene fills the view. It also activates mouse interactions to zoom and rotate the camera view. This implementation of VPython was begun by John Coady in May 2014. Ruth Chabay, Matt Craig, and Bruce Sherwood are assisting in its further development.

Installation

For more detailed instructions on how to install vpython, see https://vpython.org, where you will also find a link to the VPython forum, which is a good place to report issues and to request assistance.

Briefly:

  • If you use the anaconda python distribution, install like this: conda install -c vpython vpython
  • If you use any other python distribution, install this way: pip install vpython

Sample program

Here is a simple example:

from vpython import *
sphere()

This will create a canvas containing a 3D sphere, with mouse and touch controls available to zoom and rotate the camera:

Right button drag or Ctrl-drag to rotate "camera" to view scene.
To zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.
     On a two-button mouse, middle is left + right.
Shift-drag to pan left/right and up/down.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate.

Currently, to re-run a VPython program in a Jupyter notebook you need to click the circular arrow icon to "restart the kernel" and then click the red-highlighted button, then click in the first cell, then click the run icon. Alternatively, if you insert `scene = canvas()`` at the start of your program, you can rerun the program without restarting the kernel.

Run example VPython programs: Binder

Installation for developers from package source

You should install Cython (conda install cython or pip install cython) so that the fast version of the vector class can be generated and compiled. You may also need to install a compiler (command line tools on Mac, community edition on Visual Studio on Windows).

If you don't have a compilier vpython should still work, but code that generates a lot of vectors may run a little slower.

To install vpython from source run this command from the source directory after you have downloaded it:

pip install -e .

The -e option installs the code with symbolic links so that change you make show up without needing to reinstall.

If you also need the JupyterLab extension, please see the instructions in the labextension folder.

vpython build status (for the vpython developers)

Build Status Build status

Working with the source code

Here is an overview of the software architecture:

https://vpython.org/contents/VPythonArchitecture.pdf

The vpython module uses the GlowScript library (vpython/vpython_libraries/glow.min.js). The GlowScript repository is here:

https://github.com/vpython/glowscript

In the GlowScript repository's docs folder, GlowScriptOverview.txt provides more details on the GlowScript architecture.

Here is information on how to run GlowScript VPython locally, which makes possible testing changes to the GlowScript library:

https://www.glowscript.org/docs/GlowScriptDocs/local.html

If you execute build_original_no_overload.py, and change the statement "if True:" to "if False", you will generate into the ForInstalledPython folder an un-minified glow.min.js which can be copied to site-packages/vpython/vpython_libraries and tested by running your test in (say) idle or spyder. (Running in Jupyter notebook or Jupyterlab requires additional fiddling.)

Note that in site-packages/vpython/vpython_libraries it is glowcomm.html that is used by launchers such as idle or spyder; glowcomm.js is used with Jupyter notebook (and a modified version is used in Jupyterlab).

Placing console.log(....) statements in the GlowScript code or in the JavaScript section of glowcomm.html can be useful in debugging. You may also need to put debugging statements into site-packages/vpython/vpython.py.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vpython-7.6.2rc1.tar.gz (3.6 MB view details)

Uploaded Source

Built Distributions

vpython-7.6.2rc1-cp38-cp38-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.8Windows x86-64

vpython-7.6.2rc1-cp38-cp38-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.8

vpython-7.6.2rc1-cp38-cp38-macosx_10_14_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

vpython-7.6.2rc1-cp37-cp37m-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.7mWindows x86-64

vpython-7.6.2rc1-cp37-cp37m-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.7m

vpython-7.6.2rc1-cp37-cp37m-macosx_10_14_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

vpython-7.6.2rc1-cp36-cp36m-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.6mWindows x86-64

vpython-7.6.2rc1-cp36-cp36m-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.6m

vpython-7.6.2rc1-cp36-cp36m-macosx_10_14_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file vpython-7.6.2rc1.tar.gz.

File metadata

  • Download URL: vpython-7.6.2rc1.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for vpython-7.6.2rc1.tar.gz
Algorithm Hash digest
SHA256 694f4fe5044d9b8ce9fe9a18320054da401ce873ded8b3ca9f4be2dae04c483f
MD5 6114cc6aacf59244ed64d70636ffabd3
BLAKE2b-256 0aff3913415dfa65de3c7629d7e1377ee81d5d057b044fcf7a173c81603d8267

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for vpython-7.6.2rc1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0331a955cafb1cfb1729c4163d59e8a2ce80ca30ce871b8efa639ac21067afe5
MD5 835dddca2ab09e7a8c6bc58f61384f03
BLAKE2b-256 9623233473361920e2380ea5fdbe401b4518c118a707e71c76f25fdd54675843

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for vpython-7.6.2rc1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 73124be573ce8d739655d205ecca27627aa972780b5a92b5dbbcf0d66e2f8303
MD5 02a271cc94018de930b424210b8d1383
BLAKE2b-256 24248cfe8d11f0662963c3ad15866563d9f56345adca38e9593fa897f8efc20b

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for vpython-7.6.2rc1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 6887412ded9552ff0332ce494968dd7fedd301a4fe67031907d64f91e1c3281c
MD5 b5b5279fd37ea0df2ecd48172e8e0c19
BLAKE2b-256 f2765129e8b606a0c82499f8b5ddf32d810fa39cff0ca41f0d19118332351744

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for vpython-7.6.2rc1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 415c72c1b239a4ee5239fe1a916219ad3ee5c8dbd03f4195afa73bb4f831da44
MD5 4273bff95d135e891d1eeed77b0663d1
BLAKE2b-256 e4ba1ff8dd955e1305b9f73b7abfc6988b5d4036abc2a7926513e03610cbfd7e

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for vpython-7.6.2rc1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 62f9f2e77abf3224862051c7432e123e11c88812e6409887c779a5f9849c86fb
MD5 1d7060ab322765e538e2f9edc87855be
BLAKE2b-256 b1891262c4088803dec27bee2526c81efac96a6d8112e7f5edca2058e21ce26d

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for vpython-7.6.2rc1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 23b26d3302033f01a294daac3c1d17ab9d6280f92848cfeca37308215bd8e7df
MD5 91b0c00e48da98df2cc75c37f5a958b0
BLAKE2b-256 ad8b6f6dc2b9cfb677895a2994e47761921171c9e75b79dd2986d413fd14ae80

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for vpython-7.6.2rc1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 93c34f26f799f8605257d3ec701c8a38d81ec0ac829b8c6a0997c9d76b8e20f9
MD5 39c8d221d28d7373550bdb5bb7281ade
BLAKE2b-256 ef22dcedfa193424a13e2b67de4a154d27bc4a5695339c017b0183e94cade7d3

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for vpython-7.6.2rc1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a918c2dc607ffba1ccbc5d40f42be0d7ff54793e254464e6685145835d8fd7a0
MD5 1b14cc86b348a06a45edc8765d6631bf
BLAKE2b-256 b0e7f61eb9912a33c534ce68ad94a54c33abd8482785592ba90f5d23dcfd6654

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.2rc1-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.11

File hashes

Hashes for vpython-7.6.2rc1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 018064ef8673d13d84db4b9baf113214aab90a15b94849bf7558d29b6c8b99ba
MD5 1e523abc9ab53a4cc1d31de55d6f81c9
BLAKE2b-256 c3ee1067864af4d08621b48d95ae340b97370d2645a4cb51d3d37f032f890e0d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page