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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8macOS 10.14+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7mmacOS 10.14+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6m

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

File metadata

  • Download URL: vpython-7.6.2rc6.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for vpython-7.6.2rc6.tar.gz
Algorithm Hash digest
SHA256 6ef8d75bc78bff9057aa36a27940c178d842b919af45aa40e513c92c9aa95f52
MD5 6fb24f6fd7f527a3600b077aeb445c9c
BLAKE2b-256 62cb90296d30511a655f61e8bfdc6a05895a98a112c1cd91f101b96512ff0a60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for vpython-7.6.2rc6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 519da1edc16b342579e17adfdeee915353297629f829f75ff4abaf6d1ac85405
MD5 382e5474d1ba4ef6129b807fc36b710a
BLAKE2b-256 74edbc2a6a37790e2de7a2015ac957a59753ef5ab7c5f83b177d3db03bfc8dca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for vpython-7.6.2rc6-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 34ac09e9fef158eb1d7f977efe3ebae681409a560a45db7ead2a36e0255a65ef
MD5 41b5ece5fbdb198515c50b8fe2d1648c
BLAKE2b-256 1e4f5155d5f3361e706775c5eb7a41f1ecd79ba04fbd60901e17dd19a5ab6cc9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for vpython-7.6.2rc6-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 40ede9c93bf19f96c6e42fe428bb815020529ff1928a2673b0c263fb7f7f5523
MD5 7413eda377dc32fe69e1cba4e3c92d10
BLAKE2b-256 3c4d604d65c6d80045324112852f816dcc0b8d6b917bf0610e82539d4c9b443d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for vpython-7.6.2rc6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ff8a36b6b1dd48d10f294914b1980ab7635305e9ece54c207631f9cc5c13e9db
MD5 b35964b3fd168ac148c89b1e2d94d812
BLAKE2b-256 902449135b1d6565add7a2f006c4e563691f7885f4175c742e5439ef520e7b90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for vpython-7.6.2rc6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5351dd9281cd93580bac0c916e426192a7cc3511080e8471e1571bedb030638f
MD5 e70bd252c5ea34d2e13b122ac20e448e
BLAKE2b-256 612b182c3c8efb7f907e60a2d04e4fdeec4dd0b1fbb2f59e66c1441ee719594d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for vpython-7.6.2rc6-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 35f21e4044be1b9e6cdb1d7422ee64d0be960f5dc7480cf7d04b4fb92f2e4c27
MD5 ee2e00a18c8f81c763294120786afc91
BLAKE2b-256 d4bcd55bb6645ac622423b1361abd7c8aa58e14b51244cef1f764f675c4cfe02

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.8

File hashes

Hashes for vpython-7.6.2rc6-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3436fc275de6b77aeef75919beb4464f43c5b42d43e150217a4afb504e4ce84f
MD5 22294d32181ea4525d7f4681945928a9
BLAKE2b-256 563932dc79cc6cc6797b256ab48ae44f38c9baf4f561f96be368e83be18c221c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for vpython-7.6.2rc6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 009787c40ea9a1971ffc2058f94c5a2fcf68f06c3402706206c18bea9612b445
MD5 7d750b6bbbac627950abfb33d4bb9738
BLAKE2b-256 8017fe4a2b3cdb2082dfff6603f337d5576f23839c671cb3bab0545c5e98370f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.2rc6-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.6.1 requests/2.25.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.12

File hashes

Hashes for vpython-7.6.2rc6-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ade43bcd15da85249e04763dcdca684267bb89708dcb11cf264624b9b14a0eab
MD5 d6d7b13a4904a5a7c6d93e7441dcce82
BLAKE2b-256 5db42b669e1af3957c8ef032293b3727b2637793fb367b9edc2509b371345bd8

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