Advanced Tutorial Python PythonPip pip

Example 4: Installing additional Python packages using the PythonPip module

Introduction

MeVisLab already comes with a lot of integrated third party software tools ready to use. Nevertheless it might be necessary to install additional Python packages for your specific needs. This example will walk you through the process of adding packages through usage of/using the PythonPip module.

The PythonPip module allows to work with the Python package manager pip. It can be used to install Python packages into the site-packages of the MeVisLab Python installation.

It technically provides the full Python package ecosystem, though you will have to keep some things in mind to avoid your newly added packages to interfere with the existing ones that MeVisLab operates on:

  • Packages can contain C-Extensions (since we use the same MSVC compiler resp. same GCC settings as Python 3 itself), but you can only install packages that do not interfere with packages or DLLs that are already part of MeVisLab. This means that installing packages with C-Extensions might work in many circumstances, but is not guaranteed to work
  • All installed packages with C-Extensions are release only, so you can only import them in a release MeVisLab (under Windows)

Packages that you should not upgrade or install (because they have been adapted for MeVisLab):

  • vtk
  • cv2 (OpenCV)
  • PySide2 / PyQt (we have our own PythonQt binding and our own Qt DLLs)
  • matplotlib

These are some of the most important packages that have been adapted for MeVisLab. If you seem to have a problem upgrading another one that is not listed here, make sure to ask in the MeVisLab forum or directly contact our developers via EMail.

Working with the PythonPip module on your MeVisLab workspace

The module PythonPip can be found via module search. It provides a user interface showing the currently installed Python packages including version and MeVisLab package it has been installed to.

PythonPip interface

PythonPip interface

Select the package to install the Python package into, write the name of the package and click install.

In case you want to install a specific version, you can also use ==1.2.0

Thirdparty information and *.mli files are updated automatically.

Using the commandline

Another option is using the commandline tool provided by MeVisLab. Under Windows, you need to change to directory Packages\MeVis\ThirdParty\Python first.

commandline

MeVisPython -m pip ...

In Example 1: Installing PyTorch using the PythonPip module we are installing PyTorch to use it in MeVisLab scripting.

Summary

  • The PythonPip module allows to install additional Python packages to adapt MeVisLab to a certain extent