VPython 7 is the latest version of VPython which can be used with Python3 in Ubuntu 18.04. VPython installation using pip in Python3 has been explained in this tutorial.
Ubuntu 18.04 (Bionic Beaver) is a latest version of Linux distribution Ubuntu. Python 2.7 has been upgraded to Python3 in Ubuntu 18.04. If you want to used latest version, VPython 7 then you can go for one of the three methods:
- Online compilation on website like GlowScript.
- Installing VPython 7 on Python 2.7 with Jupyter Notebook Environment.
- Installing VPython 7 on Python3.
The first method is straight forward, you just have to go to online compiler and run your code there. Since, new Ubuntu is having Python3, I would like to use third method to install VPython 7.
Pip3 installation in Python3
Now the VPython is available as a module in Pip. You can install various modules in python through Pip. In Python 2.7, we use Pip whereas Pip3 should be used for Python3. You can install Pip3 by using following command in terminal
sudo apt install python3-pip
VPython 7 installation in Python3 through Pip3
Now Pip3 is installed in Python3, so we can proceed to install VPython 7 with following command
pip3 install vpython
It will take some time to download and install vpython. Once the VPython installation is finished it is ready to use.
Running VPython 7
After the VPython installaltion, you can test it in terminal itself. First open python3 by typing following command in terminal
Now, a new enviroment will open in terminal where you can see python version and other information. In this new environment, you can type any python command. Now lets import VPython and create a box.
from vpython import* box()
Now a new tab will open in your browser where you can see a white box which can be rotated with mouse.
If you have question, please feel free to use comment box.