Geometry Processing Research in Python
Since this is a Python tutorial, we will start by setting up a Python environment.
Python's great advantage is its extreme ease of use, but if you're not careful, then the many different versions of Python and its packages installed in your environment can quickly become a big mess. Because of this, I like to set up a new Python virtual environment for each project of mine. There are multiple ways to do this -- the two most popular ones are probably venv and conda. For the purposes of this tutorial, we will be using venv. If you prefer to use conda, everything here should work exactly the same as long as you install the same packages with the same versions.
venv comes built-in with modern versions of Python. If you have Python 3.10 or higher (the version supported by this tutorial) installed, you already have venv. If you do not have Python installed on your machine, go install the newest version of Python now. The official Python website features detailed installation instuctions.
If you already have Python installed, then
- open your command line;
- navigate to the root directory of this tutorial;
- and create a new venv by issuing the following command (your Python executable might have a different name, such as
python,python3orpython3.10):
python3 -m venv gpOnce your venv is created, you can activate it with
source gp/bin/activateon Mac/Linux, or
gp\Scripts\activateon Windows.
This is what creating and activating a new Python venv looks like on my Mac.
In this tutorial, we will use the packages Gpytoolbox, Polyscope, NumPy, and SciPy.
You can install them into your venv using the console command
python -m pip install numpy==1.26.4 scipy==1.13.1 gpytoolbox==0.2.0 polyscope==2.2.1Let's now start Python to see whether all packages installed correctly.
You can either save your Python commands in a file myfile.py and then
run it with
python myfile.pyor you can boot up python in interactive mode with
pythonand issue all commands line-by-line (end your session with quit() or CTRL+D).
If you follow along this tutorial and want to use interactive mode, please
quit Python and enter a fresh Python session before pasting in a new set of
commands.
Personally, if I have to run fewer than 3 commands, I will go into interactive
mode, otherwise I find it easier to just have a working script script.py
that I repeatedly call with python script.py.
So, whether in interactive mode or in your own file, import all our installed packages and try to run a few basic commands:
import gpytoolbox as gpy
print(gpy.__version__)
import polyscope as ps
print(ps.np.__version__)
import numpy as np
print(np.__version__)
import scipy as sp
print(sp.__version__)You should be seeing the output:
0.2.0
1.26.4
1.26.4
1.13.1
If this is what you get, then congratulations! All packages have been installed correctly. You can continue on to the first real exercise, exercise_01.
Oded Stein 2024. Geometry Processing Research in Python