# Running Python Script Gives Error

**URL:** <https://forum.knime.com/t/running-python-script-gives-error/14517>\
**Category:** KNIME Analytics Platform\
**Created:** [March 24, 2019, 3:50pm UTC](https://forum.knime.com/t/running-python-script-gives-error/14517 "2019-03-24T15:50:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Feras85](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/f/8e8cbc/32.png) [@Feras85](https://forum.knime.com/u/Feras85)\
**Post date:** [March 24, 2019, 3:50pm UTC](https://forum.knime.com/t/running-python-script-gives-error/14517/1 "2019-03-24T15:50:43Z")

</div>

I am fairly new to Knime and Python and I was checking some codes in Python that I would like to run on Python Script Node through Knime. The script executes fine through the node but not outside it, plus, the data does not show correctly on output panel for “Poisson Model” attribute on following script:

```auto
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn
from scipy.stats import poisson,skellam
import statsmodels.api as sm
import statsmodels.formula.api as smf

epl_1617 = input_table

poisson_model = smf.glm(formula="input_table['GOALS'] ~ 
input_table['HOME'] + input_table['HomeTeam'] + 
input_table['AwayTeam']", data=epl_1617, 
                    family=sm.families.Poisson()).fit()

poisson_model.summary()

```

When I run the above code on Python it gives the result in form of a table; however, in Knime the output is shown as "poisson\_model: "

Note: the input file can be downloaded from:

[http://www.football-data.co.uk/mmz4281/1617/E0.csv](http://www.football-data.co.uk/mmz4281/1617/E0.csv)

Any idea on how to run the following code on Knime?

Your help is already appreciated!

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [March 24, 2019, 4:25pm UTC](https://forum.knime.com/t/running-python-script-gives-error/14517/2 "2019-03-24T16:25:10Z")

</div>

Question is what kind of output you would expect. KNIME and Python would typically have three generic outputs

1. data manipulations etc using Python
2. build prediction models and save them
3. use graphic packages like seaborn and export graphics (as PNG)

I modified an earlier example to show all three (if you just save results from Python you might use much more), and also there is the ability to integrate Jupyter notebooks in KNIME.

 ![image](https://forum-cdn.knime.com/uploads/default/original/2X/b/b2dd808066b81313085ceec16dfd2503aaa0e700.png)

[kn\_example\_python\_logistic\_regression\_iris\_graphic.knwf](https://forum-cdn.knime.com/uploads/default/original/2X/6/6196a2d8aad5147424a39de1f9fea85494ec9e3d.knwf) (259.7 KB)

——  
Edit: [KNIME and Python — Setting up and managing Conda environments | by Markus Lauber | Low Code for Data Science | Medium](https://medium.com/low-code-for-advanced-data-science/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539)

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:33pm UTC](https://forum.knime.com/t/running-python-script-gives-error/14517/3 "2023-06-23T20:33:13Z")

</div>


