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

Uploaded Source

Built Distributions

vpython-7.6.1b9-cp38-cp38-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.8Windows x86-64

vpython-7.6.1b9-cp38-cp38-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.8

vpython-7.6.1b9-cp38-cp38-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.8macOS 10.13+ x86-64

vpython-7.6.1b9-cp37-cp37m-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.7mWindows x86-64

vpython-7.6.1b9-cp37-cp37m-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.7m

vpython-7.6.1b9-cp37-cp37m-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.7mmacOS 10.13+ x86-64

vpython-7.6.1b9-cp36-cp36m-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.6mWindows x86-64

vpython-7.6.1b9-cp36-cp36m-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.6m

vpython-7.6.1b9-cp36-cp36m-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.6mmacOS 10.13+ x86-64

File details

Details for the file vpython-7.6.1b9.tar.gz.

File metadata

  • Download URL: vpython-7.6.1b9.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b9.tar.gz
Algorithm Hash digest
SHA256 0721815ebd472375942927f38a4b27b0830122a4d2926da164eca699972477f6
MD5 3ed1ece9c3fd443ac83d95ec2445189f
BLAKE2b-256 6bc5461d5e3715e92cff2408222d0d84aba26d2bf08a4fea055217aa4117f904

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 594889eb2f0e45838b147ba299020807dfff90d4a532ce2315f1a2f90b0b34e4
MD5 86d1bc47814f0e9b281e983eb715edd9
BLAKE2b-256 b31e562c7c7f14171ac67400f8d5afc2fc2fd2be2727c86c88858271fa6d451a

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b9-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3d70f9b9de120e94018cc2fe1b82aadc8ad767e05f9fbf6246c534e1c18220ba
MD5 7f93aaa5cfb62be2358515d57d7b06ad
BLAKE2b-256 8a73e1fc46fd78cea7cb19bfe7e869c97f1b1fc3b44520d0c5fa18362d6edcf9

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp38-cp38-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-cp38-cp38-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.8, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b9-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d10af259e1314756528a30c77fc3573cba06faf799bd63039c458a5f79faff3a
MD5 185504883435ee9e5f8fa6a3470220c5
BLAKE2b-256 5a9390fead5e286787477f2c465d8e45241796e72a5ee9a664fde9585510abe8

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for vpython-7.6.1b9-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0d64755d1d4c9d72c1c7b0fe111952e16e9049d32b3230537e42c460a2c7b99c
MD5 13c41f66cc6d1d4268814bcc4ca99489
BLAKE2b-256 9d3c7c16d708cf941d504838a2550ee6feff9fd9764c2fe325b0325c8299912c

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b9-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 808b4d1bba15c4fecd742f69659ed884904f09590500f3c5caad30249e6e5164
MD5 81265c9db53108c2e240641fb88753e3
BLAKE2b-256 37f352f8435a01e6d8ca8940de6c9e4378ab18d044ef6b26db01c94bd0032aa0

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp37-cp37m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-cp37-cp37m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.7m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for vpython-7.6.1b9-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 194f66da67844cd33ad6346b0aac9d43ec612cd7022b1be486f95d378496017b
MD5 b930782e3c19039c686a063880933210
BLAKE2b-256 f3622b119ad635e5be162b7e21d0507259594438a3d6f22c6b76dc393884d915

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for vpython-7.6.1b9-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 7c9055a23d47689fc1301e67438fd7a5654c3f33fa953cb3ff2b31d7710c6ecd
MD5 7a5e10d17efba1ea48a46759e920722a
BLAKE2b-256 60aeb8d4eafae68c62e02bdae9e8d8604baaf91656d368b564b89441b63e098d

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b9-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b78411537fee16a945b2d8e2b3324111d0122779e38d39abea7dbdbd295944e3
MD5 ad8f75c237ad45801d609566aaabf7ef
BLAKE2b-256 30ec9d990fe1ff19b801a7e8400aad0a142d8f2fe59fb0ed381cad56d9e6194d

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b9-cp36-cp36m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b9-cp36-cp36m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.10

File hashes

Hashes for vpython-7.6.1b9-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3e2006b18b0dfd80a711995641048520decd9c7fad05fd98ab92fb43f93cfebb
MD5 7ea391298d448fb96a5f200707179e02
BLAKE2b-256 a18298936d9cf8ea1c3205380de15e89138b78585dc018afe83344ec590bd402

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