# Python Script and H2O Data Frames - Error under Windows

**URL:** <https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099>\
**Category:** KNIME Extensions\
**Tags:** scripting\
**Created:** [February 17, 2020, 2:06pm UTC](https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099 "2020-02-17T14:06:05Z")\
**Posts on this page:** 7\
**Page:** 1

<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:** [February 17, 2020, 2:06pm UTC](https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099/1 "2020-02-17T14:06:05Z")

</div>

@ScottF / @SimonS - following up on our discussion [here](https://forum.knime.com/t/h2o-ai-automl-in-knime-for-classification-problems/20923/9). I would like to adress the H2O/windows problem in a more systematic way.

I wrote a wrapper for H2O.ai’s AutoML to be used with KNIME. On MacOSX and Linux it seems to work. Under Windows I encounter a strange problem I would like the community and the KNIME developers to know.

The problem appears when one tries to load a Pandas data frame into H2O data frame. It does work under:

- MacOSX wrapped with KNIME Python Script
- MacOSX in Jupyter notebook
- Windows in Jupyter notebook

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

but not wrapped in KNIME. And although the error message is related to H2O the cause seem to be some implementation or versions in KNME Python scripting.

The workflow below illustrates that with a simple example trying to load the iris dataset into Pandas and then further into H2O but also directly loading parquet files from the local disc into H2O directly (which also should be possible).

And as stated. It does work with ‘pure’ Jupyter notebooks but not under KNIME. And yes I have tried to set the encoding to UTF-8 in the KNIME ini 🙂

The subfolder /script/ contains the Jupyter notebooks as well as a knime.log and debug log.

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

Here is a reduced workflow to illustrate the problem:

> **[Problem on Windows when transfering data from Pandas to H2O (solved) – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/latest/kn_problem_h2o_python~TE0cohqJI7Lp8Ai_)**
>
> When transfering data within the Python Script node from a pandas data frame to H2O cluster on Windows there seems to be a strange problem. The command works w…

---

<div class="post-metadata">

**Author:** ![ScottF](https://forum-cdn.knime.com/user_avatar/forum.knime.com/scottf/32/61316_2.png) [@ScottF](https://forum.knime.com/u/ScottF)\
**Post date:** [February 17, 2020, 6:41pm UTC](https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099/2 "2020-02-17T18:41:00Z")

</div>

Hi @mlauber71 -

Thanks for this. I’ll ask internally and see if we can’t figure out why this is happening. Or maybe @SimonS has an idea already. 🙂

---

<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:** [February 21, 2020, 5:22pm UTC](https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099/3 "2020-02-21T17:22:23Z")

</div>

Hi guys,

Looking at posts such as [this](https://www.reddit.com/r/learnpython/comments/350c8c/unicode_python_3_and_the_windows_console/) or [this](https://github.com/llSourcell/twitter_sentiment_challenge/issues/1) suggests that this is because KNIME uses Windows cmd/batch files to launch Python. Apparently, the Windows command line does not fully support UTF-8 encoding by default.

In the above posts, there are some suggestions for enabling this support. These two seem most promising:

- Turn the Windows console into UTF-8 mode via command `chcp 65001`. If you are using the “Manual” mode on the KNIME Python preference page (i.e., you are using a start script to launch Python), you could try to prepend this line to the start script.
- Or, install [win\_unicode\_console](https://anaconda.org/anaconda/win_unicode_console) in your Python environment and prepend

```auto
import win_unicode_console
win_unicode_console.enable()

```

to the Python script inside the Python node.

I have not tested any of the suggestions and would appreciate it if someone could try them out. Especially the first solution would be interesting since it requires no additional Python packages, and it is something that KNIME could do internally when the “Auto” option is selected on the KNIME Python preference page, so no user action would be required in the scripting nodes.

Marcel

---

<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:** [February 24, 2020, 9:07am UTC](https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099/4 "2020-02-24T09:07:13Z")

</div>

@MarcelW thank you for your effort and the suggestions. I think they put me on the right track with actually studying the error message and thinking about waht is going on.

It was the progress bar in H2O that would use characters that the KNIME/Windows console would not like and would refuse to fix using you suggestions. In the end I just introduced:

> h2o.no\_progress()

So no more progress bars inside the wrapper (which would not be of any real help) and now it does work. Still might be a point for KNIME or H2O to see that these progress bars with their (block ?) characters would not interfer with scripts from within KNIME.

I will mark this as solved when I have done some more tests.

---

<div class="post-metadata">

**Author:** ![ScottF](https://forum-cdn.knime.com/user_avatar/forum.knime.com/scottf/32/61316_2.png) [@ScottF](https://forum.knime.com/u/ScottF)\
**Post date:** [February 25, 2020, 8:15pm UTC](https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099/5 "2020-02-25T20:15:31Z")

</div>

@MarcelW - Just as a quick followup here, I gave both of these options a try. On my system:

- using `chcp 65001` seems to have no effect that I can tell
- ` win_unicode_console.enable()` fails with error `'_Logger' object has no attribute 'encoding'` before I even get to executing the rest of the script

I’m happy to followup on either of these if you think it’s worth the time. But @mlauber71’s fix for the progress bar seems to work fine regardless.

---

<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:** [February 25, 2020, 8:24pm UTC](https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099/6 "2020-02-25T20:24:33Z")

</div>

@ScottF I tried several things alongside the ideas of @MarcelW but to no avail. I think it would be good if the windows console (call?) could handle UTF-8 characters but I am not sure how to achieve that. If KNIME could come up with a standard solution that would be good - but maybe not the highest priority.

Having said that - I encounter an increased interest in ‘wrapped’ solutions with KNIME where additional functions / packages in R and Python are made available through KNIME so stability in these wrapped nodes is a thing.

Admittedly using strange block characters as a progress bar is not your common problem with commands at the console.

---

<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:** [March 3, 2020, 8:24pm UTC](https://forum.knime.com/t/python-script-and-h2o-data-frames-error-under-windows/21099/7 "2020-03-03T20:24:36Z")

</div>

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