Which Python versions works better with Knime?

Continuing the discussion from Error while loading data into python:

Hello everyone,
I’m using Python 3.6 and was trying to upgrade it to 3.8, since one of the imported libraries within Python Script node (Snscrape) requires Python 3.8. With Python 3.6 it causes an error “AttributeError: ‘Tweet’ object has no attribute ‘user’”

So, I came across the attached post, and what I understand that version 3.6 works better with Knime? if that was right, how could we deal with libraries that require versions >3.6?

With thanks & appreciation,

@JayR the thing is you will have to find the right combination of Python version and packages that would work with KNIME as well as your individual packages

What I would do

  • install Miniconda on your system (how to manage environments)
  • Choose a major Python version (like 3.8) that would most likely work with you package
  • look up a suitable YML file provided by KNIME (python version and operating system)
  • edit the file so it would suite your initial needs. Use only ‘conda-forge’ and add additional packages at the end and packages that are only available via PIP under the entry

For MacOS it might look like this:

name: py38_knime_2022    # Name of the created environment
channels:                # Repositories to search for packages
- conda-forge
dependencies:            # List of packages that should be installed
- pip
- python>=3.8,<3.9       # Python version
- py4j                   # used for KNIME <-> Python communication
- nomkl                  # Prevents the use of Intel's MKL
- pandas                 # Table data structures
- jedi                   # Python script autocompletion
- python-dateutil        # Date and Time utilities
- numpy                  # N-dimensional arrays
- cairo                  # SVG support
- pillow                 # Image inputs/outputs
- pyarrow=6.0            # Arrow serialization
- IPython                # Notebook support
- nbformat               # Notebook support
- scipy                  # Notebook support
- jpype1                 # Databases
- python-flatbuffers<2.0 # because tensorflow expects a version before 2
- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned
- protobuf>3.12
- libiconv               # MDF Reader node
- asammdf=5.19.14        # MDF Reader node
# ----------------------------------------------------
- openpyxl              # Excel Reader
- scikit-learn          # Machine Learning
# Visualization
- matplotlib
- bokeh
- seaborn
- pip:                   # add packages that would be installed thru PIP
  - snscrape             # scraper for social networking services

Create the environment via the miniconda prompt.

You can read more about how to use KNIME and Python in the guide:

https://docs.knime.com/latest/python_installation_guide/index.html#_introduction

2 Likes

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