Skip to content

Script Development / Installing Third-Party Packages

After DataFlux Func is installed, since DataFlux Func itself requires third-party packages, these packages can be used directly in scripts without additional installation.

For the specific list of pre-installed third-party packages, see "Management / PIP Tool". The packages marked as Yes in the "Built-in" column are the pre-installed third-party packages.

If users need to install additional third-party packages, they can also install them in "Management / PIP Tool".

1. Installing Python Packages with Public Network Access

If the DataFlux Func that needs additional third-party packages can directly access the public network, you can directly use the built-in "PIP Tool" to install them.

1.1 Enabling the "PIP Tool"

Enable "PIP Tool" in "Management / Experimental Features".

enable-pip-tool.png

1.2 Installing Third-Party Packages

In the "PIP Tool", you can select a PyPI mirror, enter the package name, and install it.

If you need to specify a version number, you can install it using the format package==1.2.3.

install-package.png

Selecting a Mirror

If your server cannot directly access PyPI for some reason, you can choose a different PIP mirror.

2. Installing Python Packages without Public Network Access

If the server where DataFlux Func is located cannot access the external network for various reasons, the usual PIP method cannot install third-party packages.

In this case, you need another DataFlux Func with the same architecture that can access the public network to install the third-party packages. After installation, copy the entire extra-python-packages directory to the DataFlux Func that cannot access the public network.

Hereafter, the DataFlux Func that can access the public network is referred to as "Online Func"; the DataFlux Func that cannot access the public network is referred to as "Offline Func"

2.1 Installing Third-Party Packages on the Online Func

For this step, refer to the earlier section "Installing Packages from PyPI When You Can Access the Public Network" above

2.2 Enabling the "File Manager Module"

Enable "File Manager Module" in "Management / Experimental Features".

enable-file-manager.png

2.3 Downloading the Third-Party Package Directory from the Online Func

Find the extra-python-packages directory (all additionally installed Python package contents are stored here), select "More / Compress", and download the zip file.

zip-pkg.png

download-pkg.png

2.4 Uploading the Third-Party Package Directory to the Offline Func

Go to the "Offline Func", delete the original third-party package storage directory, upload the zip file downloaded in the previous step, and unzip it.

delete-pkg.png

upload-pkg.png

unzip-pkg.png

unzip-pkg-done.png

2.5 Restarting the Offline Func

For this step, refer to Deployment and Maintenance / Upgrade and Restart

Notes

DataFlux Func runs in Docker, and the Python runtime environment also depends on the environment in the container.

Therefore, do not copy Python installation contents from the local machine or from any non-DataFlux Func container into DataFlux Func. Otherwise, strange problems will often occur.

In addition, the "Online Func" and "Offline Func" must have the same hardware architecture, for example both x86_64 or aarch64

Uploading a Wheel file to the server and then installing it directly via PIP is theoretically feasible, but in the vast majority of cases it will not succeed.

The reason is that the uploaded Wheel file itself may depend on other packages. Simply uploading the Wheel package directly used in the code cannot satisfy the dependencies. Generally, the more powerful a package is, the more other packages it depends on, and the deeper the dependency chain. Ultimately, this may plunge the operator into dependency hell.

Therefore, unless the package to be installed does not depend on any other package, it is generally not recommended to install third-party Python packages by uploading Wheel files.