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)

Testing workfloww

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.2rc11.tar.gz (3.6 MB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8Windows x86-64

vpython-7.6.2rc11-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.8macOS 10.14+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

vpython-7.6.2rc11-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.7mmacOS 10.14+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

vpython-7.6.2rc11-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64manylinux: glibc 2.5+ x86-64

vpython-7.6.2rc11-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.2rc11.tar.gz.

File metadata

  • Download URL: vpython-7.6.2rc11.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for vpython-7.6.2rc11.tar.gz
Algorithm Hash digest
SHA256 1818f2af3a472524e0f6268556e16b033e7245708ba732db8f3f0720ea0d2456
MD5 cde19b9f7bf16045192a4b2c91b47d0f
BLAKE2b-256 3b40c38da3b80cd3b8f0c4a55acc7a09c4807529008c33c89ef88a317d0147ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc11-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.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for vpython-7.6.2rc11-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 15fccc8740d36fa5074470a83f3eaadc6b64182a9d115a357e6b750829404b95
MD5 1234e582608cd3c9a9151fb6daf13e21
BLAKE2b-256 1a31bd9e5a0f02be95a945db7ef087de6ddb66e740e0b5ddb8a53cec1fd3885e

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc11-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for vpython-7.6.2rc11-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 77dbf328481894c3a121d44a2c881f7a7a9e627957e13dcac52b682c32465f9f
MD5 6aefe4f8ecb50c6f0a21a8d14c61fed1
BLAKE2b-256 1b8bf24651cfa0545cc38ee2a725fcc3c44b8de5a1a7187b32b7de048e76af37

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc11-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.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for vpython-7.6.2rc11-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 abe29ce9b13d50e129d9f583d4a68bf07cbb88840428553ea403bd9a29f07474
MD5 302b368ad64a049b398b69af56f3f649
BLAKE2b-256 6fbfdc27a52f6ff9bdb60f7816982c0858f4794d14024cfebaa353db252c0035

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc11-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.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.9

File hashes

Hashes for vpython-7.6.2rc11-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0ebcd8762ef642f0000bbe3615c437c3ff246d8d99187348bb963265c5fdbf2a
MD5 257042d44972c054ad221cdfe2806c91
BLAKE2b-256 58a75b472b0661f0173c73949948079f004071a19d2377f22db55511dab061f8

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc11-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for vpython-7.6.2rc11-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a738e5a98fe9ca4a24af8c93bebeb6c97371fbfe535ac7b5c464984124fc421b
MD5 4d44e6e01e1a4217e41a47a679619f83
BLAKE2b-256 f523153c4a8cad288349816f4e327f36e342e72a1ae0c99533b6fde364150e7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc11-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.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.11

File hashes

Hashes for vpython-7.6.2rc11-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a1584c4b062d7414a82c66ef938e271efebe680b196289406ddc5c09d7a51da7
MD5 9da29bf209b549e2b21934323f6fe76d
BLAKE2b-256 ff5b1739d9f49f13d9f18a59bcaea9b9abdac5f61941edf3e2dc9b67e44d0581

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc11-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.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.8

File hashes

Hashes for vpython-7.6.2rc11-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 ee3ede6415e0816c5a9bc274934db2c30bd6ba6d33fff25e032af4727cd9afd6
MD5 49694911386a8bb2ef3b7947f0b0baf4
BLAKE2b-256 092d9aead4c45fc171d6edbecdf95e153840eb617651bfa6aaa24186c83ab969

See more details on using hashes here.

File details

Details for the file vpython-7.6.2rc11-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for vpython-7.6.2rc11-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b01752262fd8410243c6a718fed6462c882b751c61d99bd5a89289d6dabdb0bd
MD5 16dcca4686d8fd46345ae148b44de8f7
BLAKE2b-256 21e01af244b48848f4226fa5429c80665d59450f6144d9fe9002c5fb45d0a9cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc11-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.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.14

File hashes

Hashes for vpython-7.6.2rc11-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 3248b30bdd53c41a01a537c593f9d17d57576088919938738a577de404373481
MD5 3d1eedb4a4da6d72d682982e7f18a7d9
BLAKE2b-256 2c52e334e8d0e48081c938fac0df7ce6237dbaa5c97d99e575cceeec1acf8610

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