# Python Script node and Jupyter notebook integration error

**URL:** <https://forum.knime.com/t/python-script-node-and-jupyter-notebook-integration-error/29899>\
**Category:** KNIME Extensions\
**Tags:** scripting\
**Created:** [January 12, 2021, 7:21pm UTC](https://forum.knime.com/t/python-script-node-and-jupyter-notebook-integration-error/29899 "2021-01-12T19:21:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![MarcelW](https://forum-cdn.knime.com/user_avatar/forum.knime.com/marcelw/32/352_2.png) [@MarcelW](https://forum.knime.com/u/MarcelW)\
**Post date:** [January 13, 2021, 1:13pm UTC](https://forum.knime.com/t/python-script-node-and-jupyter-notebook-integration-error/29899/2 "2021-01-13T13:13:35Z")

</div>

Hi @fbagirov,

I am afraid this will not work the way you would like it to, given how our Jupyter integration is currently designed.  
`knime_jupyter.load_notebook` loads the Jupyter notebook into the node’s “main” Python script as a separate Python module (comparable to what Python’s `import` statement does). In Python, the [namespaces/scopes](https://docs.python.org/3/tutorial/classes.html#python-scopes-and-namespaces) of the variables of two different modules are isolated from one another, that is, code inside the notebook cannot simply reference variables declared in the node’s main Python script. So some mechanism will be necessary to explicitly pass the required variables from the main script to the notebook. Right now, this is only possible by means of function calls (like the one in line 30 in your screenshot, where `ìnput_table` is explicitly being passed to `my_notebook.sum_each_row`). So the only solution that comes to mind would be to remodel your notebook such that all cells that require external input become functions:

```auto
def calculate_centroid(df):
  df['the_geom'] = df['the_geom'].apply(wkt.loads)

```

Come to think of it, it would be really cool to be able to do something like this:

```auto
notebook = knime_jupyter.load_notebook(notebook_directory, notebook_name, vars={'df' : df})

```

Would that be interesting for you? Then I would create a feature request for that (or some comparable mechanism).

Marcel

---

_[View the full topic](https://forum.knime.com/t/python-script-node-and-jupyter-notebook-integration-error/29899)._
