Knime - Python Script none type object has no Attributes as_py

This code appears to work in jupiter notebook but when i have slightly adapted the input tables i am getting the following error,
Executing the Python script failed: Traceback (most recent call last):
File “”, line 6, in
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\”, line 8913, in stack
result = stack(self, level, dropna=dropna)
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\reshape\”, line 607, in stack
new_values = frame._values.ravel()
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\”, line 5902, in getattr
return object.getattribute(self, name)
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\”, line 970, in _values
return self.values
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\”, line 5902, in getattr
return object.getattribute(self, name)
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\”, line 11736, in values
return self._mgr.as_array()
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\internals\”, line 1767, in as_array
arr = self._interleave(dtype=dtype, na_value=na_value)
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\internals\”, line 1814, in _interleave
arr = blk.get_values(dtype)
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\internals\”, line 1604, in get_values
values = values.astype(object)
File “C:\Knime\knime_4.7.1\plugins\org.knime.python3.arrow_4.7.1.v202301311311\src\main\python\”, line 918, in astype
return super().astype(dtype, copy)
File “C:\Knime\knime_4.7.1\plugins\\env\lib\site-packages\pandas\core\arrays\”, line 610, in astype
return np.array(self, dtype=dtype, copy=copy)
File “C:\Knime\knime_4.7.1\plugins\org.knime.python3.arrow_4.7.1.v202301311311\src\main\python\”, line 951, in array
[self[i] for i in range(len(self))],
File “C:\Knime\knime_4.7.1\plugins\org.knime.python3.arrow_4.7.1.v202301311311\src\main\python\”, line 951, in
[self[i] for i in range(len(self))],
File “C:\Knime\knime_4.7.1\plugins\org.knime.python3.arrow_4.7.1.v202301311311\src\main\python\”, line 628, in getitem
return self._data[item].as_py()
File “C:\Knime\knime_4.7.1\plugins\org.knime.python3.arrow_4.7.1.v202301311311\src\main\python\”, line 463, in as_py
return self._ext_type.decode(self.value.as_py())
AttributeError: ‘NoneType’ object has no attribute ‘as_py’

Does anyone have any ideas ?

@LukeParkes welcome to the KNIME forum. You will have to convert the pandas dataframe (if it is one) back to Arrow before bringing it back to KNIME.

# data from python (pandas) to KNIME
knio.output_tables[0] = knio.Table.from_pandas(sh_w) 

Hi @LukeParkes,

I agree with the suggestion from @mlauber71. You need to convert the table to make the script work.

However, the error seems to appear earlier (in line 6 of your script). Some pandas internals fail to work with our special array implementations. I looked into our code and found that it was changed recently. The relevant line reads now self.value.as_py() if self.value is not None else None (GitHub - knime-python - It seems that this change would solve the issue but it is not available in 4.7.1. Can you try your script in KNIME AP 5.0? If it is fixed, we can check if we want to backport the fix for 4.7.3.


Hi @bwilhelm, i have tried changing this code in my own version of knime and this has worked thank you, if i was to put this on a knime server though i imagine i would get the same issues as it won’t have this change built into the server ?

Hi @LukeParkes,
Thank you for verifying that my suggestion helps. You are right, the server will use its own installation of the Python integration which still contains the buggy code. We backported the change and it will be released with 4.7.3. However, the 4.7.3 release is not planned yet so I cannot give you a date.

1 Like

Hi @bwilhelm, okay no worries, please could you update me when there is a planned date! thank you

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

Hi @LukeParkes,
KNIME Analytics Platform 4.7.3 is available now.

1 Like