Skip to main content

Use Python packages

App dependencies can be specified in your app's requirements.txt file. The first line of the file is reserved for specifying the VIKTOR SDK version to be used in the app. All other dependencies can be added underneath the usual way. For example:

# viktor==X.X.X
drawSVG==1.3.1

Pinning version number and version clashes

Both the VIKTOR SDK and drawSVG package have an explicit version number defined (pinned version numbers). This is done to ensure that your app always uses the same version. If the package maintainers release a new version overnight, this does not break your app when re-installing. By pinning the versions, you decide when to upgrade to a newer version and this enables reading the CHANGELOG which might contain necessary actions for upgrading.

It is possible that you are using a package which is also used by the VIKTOR SDK. The SDK defines a range of allowed versions. If the app specifies a version outside this range, an error will be logged:

ERROR: viktor X.X.X has requirement numpy>=1.15.3, but you'll have numpy 1.15.0 which is incompatible.

This might also happen when you don't have a pinned version number and the latest version has not yet been added to the SDK range.

caution

External packages that are internally used in the SDK are available in your app (e.g. munch), even when you don't add them to your app's requirements.txt. Nevertheless, you are highly encouraged to explicitly define them in your app requirements, as deletion of dependencies within the SDK will be done without prior notice and therefore may break your app!

caution

Some package licenses do not allow for commercial use, or requires you to open-source your implementation. Make sure the package licensing permits, before using it in your app.