ModuleNotFoundError: No module named 'knime.api.types'

Dear all,

I am attempting to write my first knime node using python and am running into an issue with a MoldeNotFoundError. Here is my python script so far:

import knime.extension as knext

@knext.node(name=“My Node”, node_type=knext.NodeType.MANIPULATOR, icon_path=“…/icons/icon.png”, category=“/”)
@knext.input_table(name=“Input Data”, description=“The data to process in my node”)
@knext.output_table(“Output Data”, “Result of processing in my node”)
class MyNode:
“”"Short description is in the first line next to the three double quotes here. It it displayed in overviews when a whole category in the node repository is selected.

Here begins the normal description: This node description will be displayed in KNIME Analytics Platform.
"""
def configure(self, config_context, input_table_schema):
    return input_table_schema

def execute(self, exec_context, input_table):
    return input_table

and here is the error output:

(my_python_env) PS C:\Users\AdamSemple> & C:/Users/AdamSemple/miniconda3/envs/my_python_env/python.exe “c:/Users/AdamSemple/OneDrive - Diaceutics/Documents/KNIME_PYTHON/myextension.py”
Traceback (most recent call last):
File “c:\Users\AdamSemple\OneDrive - Diaceutics\Documents\KNIME_PYTHON\myextension.py”, line 1, in
import knime.extension as knext
File “C:\Users\AdamSemple\miniconda3\envs\my_python_env\lib\site-packages\knime\api\table.py”, line 60, in
import knime.api.schema as ks
File “C:\Users\AdamSemple\miniconda3\envs\my_python_env\lib\site-packages\knime\api\schema.py”, line 60, in
import knime.api.types as kt
ModuleNotFoundError: No module named ‘knime.api.types’
(my_python_env) PS C:\Users\AdamSemple> & C:/Users/AdamSemple/miniconda3/envs/my_python_env/python.exe “c:/Users/AdamSemple/OneDrive - Diaceutics/Documents/KNIME_PYTHON/extension/myextension.py”
Traceback (most recent call last):
File “c:\Users\AdamSemple\OneDrive - Diaceutics\Documents\KNIME_PYTHON\extension\myextension.py”, line 1, in
import knime.extension as knext
File “C:\Users\AdamSemple\miniconda3\envs\my_python_env\lib\site-packages\knime\extension_init_.py”, line 51, in
import knime.api.table as _kt
File “C:\Users\AdamSemple\miniconda3\envs\my_python_env\lib\site-packages\knime\api\table.py”, line 60, in
import knime.api.schema as ks
File “C:\Users\AdamSemple\miniconda3\envs\my_python_env\lib\site-packages\knime\api\schema.py”, line 60, in
import knime.api.types as kt
ModuleNotFoundError: No module named ‘knime.api.types’

I would greatly appreciate any help with this you can offer!

Many thanks, Adam

Hi Adam,

good that you ask here! Could you send us the packages installed in my_python_env as a txt file?
Do so by

conda activate my_python_env
conda list > environment.txt

And send us that environment.txt

Thanks
Steffen

Hi Steffen,

Thanks for the reply, here is the .txt:

packages in environment at C:\Users\AdamSemple\miniconda3\envs\my_python_env:

Name Version Build Channel

arrow-cpp 9.0.0 py39hf1b1be8_33_cpu conda-forge
aws-c-auth 0.6.26 h0e8f9f7_6 conda-forge
aws-c-cal 0.5.26 h3200b0f_0 conda-forge
aws-c-common 0.8.17 hcfcfb64_0 conda-forge
aws-c-compression 0.2.16 h50f2975_6 conda-forge
aws-c-event-stream 0.2.20 h03f8742_6 conda-forge
aws-c-http 0.7.7 h1ea9cf2_3 conda-forge
aws-c-io 0.13.21 h09d0bb2_3 conda-forge
aws-c-mqtt 0.8.6 h9028ce9_15 conda-forge
aws-c-s3 0.2.8 h1059ad0_4 conda-forge
aws-c-sdkutils 0.1.9 h50f2975_1 conda-forge
aws-checksums 0.1.14 h50f2975_6 conda-forge
aws-crt-cpp 0.19.9 hd59d7e4_5 conda-forge
aws-sdk-cpp 1.10.57 h44051fd_10 conda-forge
bzip2 1.0.8 h8ffe710_4 conda-forge
c-ares 1.18.1 h8ffe710_0 conda-forge
ca-certificates 2023.5.7 h56e8100_0 conda-forge
gflags 2.2.2 ha925a31_1004 conda-forge
glog 0.6.0 h4797de2_0 conda-forge
importlib-metadata 6.6.0 pyha770c72_0 conda-forge
knime-extension 4.7.0 py_0 knime
knime-python-base 4.7.1 py39_202301111650 knime
krb5 1.20.1 heb0366b_0 conda-forge
libabseil 20230125.0 cxx17_h63175ca_1 conda-forge
libblas 3.9.0 5_hd5c7e75_netlib conda-forge
libbrotlicommon 1.0.9 hcfcfb64_8 conda-forge
libbrotlidec 1.0.9 hcfcfb64_8 conda-forge
libbrotlienc 1.0.9 hcfcfb64_8 conda-forge
libcblas 3.9.0 5_hd5c7e75_netlib conda-forge
libcrc32c 1.1.2 h0e60522_0 conda-forge
libcurl 8.0.1 h68f0423_0 conda-forge
libffi 3.4.2 h8ffe710_5 conda-forge
libgoogle-cloud 2.9.1 h00b2bdc_0 conda-forge
libgrpc 1.54.0 h32da247_0 conda-forge
liblapack 3.9.0 5_hd5c7e75_netlib conda-forge
libprotobuf 3.21.12 h12be248_0 conda-forge
libsqlite 3.40.0 hcfcfb64_1 conda-forge
libssh2 1.10.0 h9a1e1f7_3 conda-forge
libthrift 0.18.1 h9ce19ad_1 conda-forge
libutf8proc 2.8.0 h82a8f57_0 conda-forge
libzlib 1.2.13 hcfcfb64_4 conda-forge
lz4-c 1.9.4 hcfcfb64_0 conda-forge
m2w64-gcc-libgfortran 5.3.0 6 conda-forge
m2w64-gcc-libs 5.3.0 7 conda-forge
m2w64-gcc-libs-core 5.3.0 7 conda-forge
m2w64-gmp 6.1.0 2 conda-forge
m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge
markdown 3.4.1 pyhd8ed1ab_0 conda-forge
msys2-conda-epoch 20160418 1 conda-forge
nomkl 1.0 h5ca1d4c_0 conda-forge
numpy 1.24.1 py39h16ffa76_0 conda-forge
openssl 3.1.0 hcfcfb64_3 conda-forge
pandas 1.5.2 py39h2ba5b7c_2 conda-forge
parquet-cpp 1.5.1 2 conda-forge
pip 23.1.2 pyhd8ed1ab_0 conda-forge
py4j 0.10.9.7 pyhd8ed1ab_0 conda-forge
pyarrow 9.0.0 py39hca4e8af_33_cpu conda-forge
python 3.9.15 h4de0772_0_cpython conda-forge
python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge
python_abi 3.9 3_cp39 conda-forge
pytz 2023.3 pyhd8ed1ab_0 conda-forge
re2 2023.02.02 h63175ca_0 conda-forge
setuptools 67.7.2 pyhd8ed1ab_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
snappy 1.1.10 hfb803bf_0 conda-forge
tk 8.6.12 h8ffe710_0 conda-forge
tzdata 2023c h71feb2d_0 conda-forge
ucrt 10.0.22621.0 h57928b3_0 conda-forge
vc 14.3 h3d8a991_11 conda-forge
vs2015_runtime 14.34.31931 h4c5c07a_11 conda-forge
wheel 0.40.0 pyhd8ed1ab_0 conda-forge
xz 5.2.6 h8d14728_0 conda-forge
zipp 3.15.0 pyhd8ed1ab_0 conda-forge
zlib 1.2.13 hcfcfb64_4 conda-forge
zstd 1.5.2 h12be248_6 conda-forge

Thanks,
Adam

Hi Adam,

so just that we are on the same page. You followed this tutorial and you get this error within the KNIME Analytics Platform. Is that correct?

Because to me it seems that you try to run your file with the python executable of my_python_env from your command line as this part of your log suggests:

(my_python_env) PS C:\Users\AdamSemple> & C:/Users/AdamSemple/miniconda3/envs/my_python_env/python.exe “c:/Users/AdamSemple/OneDrive - Diaceutics/Documents/KNIME_PYTHON/myextension.py”

This cannot work.
If that was the case: which guide did you follow?

(and please format code, thanks)
Screenshot 2023-05-10 at 11.34.00

Best regards
Steffen

Hi Steffen,

Thanks for pointing out the code format, will use it in the future.
Yes that is the guide that I have followed, however I got the error in Visual Studio Code.

Thanks,
Adam

Hi Adam,

ah. So you try to use the terminal in VS Code, correct? This cannot work :slight_smile:

If you follow the guide, see step 7: start your KNIME Analytics Platform (KAP). There the node should be visible. Executing the script from any command line tool can and will not work without some bigger adjustments and it is not intended to do so. I guess we need to state that in the guide. :slight_smile:

Does the node show up in the KAP?

Best regards
Steffen

Hi Steffen,

No it doesn’t show, that’s why I thought I had to run the code in VS Code

Thanks,
Adam

Hi Steffen,

Thank you for your help and your patience, I reinstalled everything and started from scratch and now it works fine.

Thanks again,
Adam

2 Likes

Thanks for letting me know!
Weird though, I would have liked to see which step did not work.

Anyway, happy developing!
Steffen

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