passing file saved on server to python scripts

Good day,

I am trying to pass a file path of a pdf file saved on the knime server (as a string variable) to a python script node but getting the following error in the python script node:

no such file: ‘knime:/knime-server/Tech%20Team/Team%20Memebrs/Emil/knimetemp-46e44c89b5804e8e/Corporate_Actions_Notice_1141753_351980780_02012023.pdf’
Traceback (most recent call last):
File “”, line 11, in
File “C:\Users\EmilVW\AppData\Local\anaconda3\envs\py3_knime\lib\site-packages\fitz_init_.py”, line 2630, in init
raise FileNotFoundError(msg)
fitz.FileNotFoundError: no such file: ‘knime:/knime-server/Tech%20Team/Team%20Memebrs/Emil/knimetemp-46e44c89b5804e8e/Corporate_Actions_Notice_1141753_351980780_02012023.pdf’

The file path I am passing to the python script node looks like this:

knime:/knime-server/Tech%20Team/Team%20Memebrs/Emil/knimetemp-46e44c89b5804e8e/Corporate_Actions_Notice_1141753_351980780_02012023.pdf

I do not have a python environment setup on the server yet. Trying to make this work locally before attempting to run it on the server.
Please advise on the format of my file path and if it would be possible for the python script node to access files saved on the knime server when running on my local.

Hi @emilVW,
Welcome to the KNIME Forum! The problem is that Python does not know how to deal with knime:// URLs. In KNIME’s Java-based nodes we can handle those URLs ourselves and make sure they are resolved to an authenticated HTTP request to the server’s REST API. This does not work in Python, though. I would advise you to download the file first into the workflow’s data-directory and then access that from Python. You can find out the location of the data directory by using a Extract Context Properties node to get the workflow’s absolute path, then append /data to it.
Kind regards,
Alexander

2 Likes

Hi @AlexanderFillbrunn,

Your solution worked, thanks for the help! :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.