Creating venv virtual environment with vtkpython ?

I wish to create a VTK python virtual environment.

I tried

nyue@compute1:~/temp$ which vtkpython
/home/nyue/systems/VTK/9.4.1-static/bin/vtkpython
nyue@compute1:~/temp$ vtkpython -m venv .venv
Error: [Errno 2] No such file or directory: '/home/nyue/temp/.venv/bin/vtkpython'

Is that not the way to do that or should I not create virtual environment and take a different approach ?

Or should I approach this from another perspective, create a virtual environment the usual way

python3 -m venv .venv

Activate the virtual environment and install vtk

.venv\bin\activate
python -m pip install vtk

Just wondering which is the recommended approach and their pros/cons

The simplest way to use VTK in a venv is to install it: ‘pip install vtk’. (this will install the latest version)
Then you use it as any other python package.

Dan

You can also enable your home-built vtkpython in the venv by creating a link:

ln -s /home/nyue/systems/VTK/9.4.1-static/bin/vtkpython /home/nyue/temp/.venv/bin/vtkpython
1 Like