Integrate Standard Python & External Libraries in VIKTOR Apps

by VIKTOR Team

VIKTOR allows users to easily build and distribute web applications with Python. The Python ecosystem consists of the programming language itself, the standard library as well as packages developed by the massive community. With almost half a million projects on the Python Package Index, it is common to utilize packages in your VIKTOR app. The platform integrates with Python's standard libraries as well as external non-Python packages. This ensures your app is always functioning with all dependencies on cloud.

Understanding 3rd-party libraries

The basic Python library offers many helpful features, but there are also numerous community-built Python packages. These packages, created by the community, offer solutions for common tasks, making your development faster and benefiting from shared knowledge. Examples of popular third-party packages are NumPy and SciPy for scientific computing, Matplotlib for creating various visualizations, and pandas for data analysis. Your VIKTOR app might rely on these external 3rd party Python packages. Fortunately, they are easily installed with VIKTOR.

system dependencies.gif

Dependency management for VIKTOR apps

Usually, when creating scripts, you install Python packages that aren't part of the standard library using pip, the Python package manager, before you can use them. When developing or publishing VIKTOR apps, we handle this process for you. Simply include the required packages in a file called requirements.txt. Other dependencies can be included in viktor.config.toml, located in your app folder. This way, we ensure that you can use these packages in your app after publishing your app. The difference is outlined below:

req.gif

1. Standard Python packages

If a package is not a part of the Python standard library, you can include it in your requirements.txt file within your integrated development environment (IDE). For instance, you can insert packages, like NumPy, here to make sure that they are installed with your app.

2. System dependencies for external packages

Some Python packages require additional software to be installed before you can use them. During local app development, you can install the necessary software on your machine. However, when your app is published, the additional software also needs to be installed on the VIKTOR cloud to ensure the published app functions correctly. By defining the necessary packages in the viktor.config.toml file, you ensure your app gets all the required external installations on the cloud. This way, the app can function properly once it is published on the VIKTOR platform. This unified approach ensures that your app and its additional dependencies are hosted together on the VIKTOR platform.

toml.gif

Try it yourself

If you want to delve deeper into how to use system dependencies with VIKTOR, check out our detailed documentation page. Alternatively, you can share your thoughts or any tips or tricks on improving app development in the community.

Share

Related Blog Posts

What's new in VIKTOR (May 2024)

Read more

Visual Builder: Click to create your UI

Read more

What's new in VIKTOR (April 2024)

Read more