Have you done the following step, as written in the docs?
Additional security is provided by not enabling the Python script provider by default. You need to explicitly install the collaboraofficebasis6.x-python-script-provider and collaboraofficebasis6.x-pyuno packages (replace x with the respective version number) to enable Python scripts.