Guidance on Executing Python Script from Working GitHub Project

Trying to pick up a bit of coding as a hobby and also expand my KNIME horizons further. Python and KNIME together seem like an incredible combination.

I’ve been enable to install Python 3.7, create the appropriate environment, as well as install packages using Miniconda3.

There is an excellent GitHub project “RETSManager” that enables the abstraction of real estate data from a RETS (Real Estate Transaction Standard) server. I’ve been able to install this as well, and get to Step 8 under “Local Installation” where one accesses the server via the browser.

I’m looking to execute a portion of this project’s scripts within the Python Script node - just the ones responsible for connecting to the server, running a query (that will stay the same on each run), and gather the data. I’ll take care of transforming and cleansing with downstream KNIME nodes.

Based on the project structure’s scripts, those would be /rets_lib/ and

This is where I’m stuck - I’ve tried copying and pasting those scripts into the Python Script node, but I feel like a monkey playing with sticks here as all those fail and fall flat.

Any pointers in the right direction, general guidance, or tips would be sincerely appreciated.

Hi @wisemanleo -

Would it be possible for you to upload your workflow showing what you’ve tried so far, along with some more description of the specific failures you’re trying to avoid and/or relevant error messages? Then maybe someone can replicate the issues and make more detailed suggestions.

1 Like

Hi @ScottF, and thank you.

Executing Pyython Script.knwf (11.8 KB)

Attached is a “workflow” - but just the one python node. I’ve pasted inside the node two codes from the RETSManager that seem to be responsible for authenticating and retrieving: and

The node fails early on with the error:

Executing the Python script failed: Traceback (most recent call last):
  File "<string>", line 14, in <module>
KeyError: "'__name__' not in globals"

I don’t expect this code to fully authenticate yet as I’ve had to strip out the username and password, but at least if the code fails due to that, I would imagine I’d see an authentication-related error.

I have all the dependencies and requirements installed in my environment.

Wanted to add - while the code in the node is long, it is only one example of many “client libraries” I found. RETSManager makes reference to GitHub - refindlyllc/rets: A thin RETS client, and there are one or two others mentioned here as well.

I more or less run into the same issue as above when I try all of them.

I also have Ruby installed here on Windows 10, and have the Ruby script nodes in KNIME.

Hello wisemanleo,

I can see you trying to import a Class from another python file, but not mentioning the path in the code.

Can you try importing them by following the below:

  1. Place the Python files to be imported someplace inside the directory of your workflow which is located in your workspace directory. This ensures that the script also is exported if you export the workflow.

  2. Get the path to your workflow via the Extract Context Properties node (this makes your workflow portable).

  3. Pass the “context.workflow.absolute-path” flow variable to the Python Script node .

  4. Inside the python script node, add the path to your sys.path and load the files just like any other Python module :

    • import sys
      from exceptions import NotLoggedIn, MissingVersion, HTTPException, RETSException, MaxrowException



This is phenomenal - just the guidance I was looking for. Thank you @k10shetty1 - let me give this a shot and then go from there.

1 Like

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