No module named 'knime.scripting'; 'knime' is not a package

Hi,Team
When I used KNIME 4.7 python script node, it had below issue.
How to fix?

image

Python setting as below:

Hi eddy0620,

it looks like you want to use the Conda environment of the Conda Environment Propagation node. Is that correct? If yes, is the corresponding conda flow variable in the tab Executable Selection of the node selected?
The screenshot of the preferences has nothing to do with the Conda Environment Propagation node, the preferences set an environement for the whole KNIME Analytics Platform, whereas the Conda Environment Propagation node allows connected nodes and further downstream nodes to use the environment from that node, if and only if the flow variable from that node is selected in the tab Executable Selection.

To make debugging easier, could you provide the workflow? We would at least need the content of the Conda Env Prop node. Maybe you use a too old Python version here (Python<=3.3 could be the cause for this specific issue)? We recommend using Python>=3.8.

Best regards
Steffen

4 Likes

I can’t use any python script node.



test1212.knwf (30.6 KB)

Hi eddy0620,

the environment specified by your node uses the module knime from pypi. This causes the Python process of the Python nodes to crash. Please make sure you use for these nodes (or better: generally Analytics Platform-wide) environments which do not have that specific knime module installed.

Does using an environment without that package help?

Best regards
Steffen

2 Likes

I only can use Python Script (legacy) node. The 4.7 new python script node can’t use.

Did you delete the knime package from the used environment, as I suggested?
Alternatively, you can try to create a new environment on the preference page and use that one.

Let me know if my suggestions help.
Steffen

2 Likes

After I delete knime pkg , it still had the issue.
2022-12-14 23:00:52,310 : ERROR : KNIME-Worker-503-Python Script 8:2448 : : Node : Python Script : 8:2448 : Execute failed: An exception occured while running the Python kernel. See log for details.

org.knime.python2.kernel.PythonIOException: An exception occured while running the Python kernel. See log for details.

at org.knime.python2.kernel.PythonKernelQueue$KeyedPooledPythonKernelFactory.createKernel(PythonKernelQueue.java:411)

at org.knime.python2.kernel.PythonKernelQueue$KeyedPooledPythonKernelFactory.populateHolder(PythonKernelQueue.java:396)

at org.knime.python2.kernel.PythonKernelQueue$KeyedPooledPythonKernelFactory.makeObject(PythonKernelQueue.java:381)

at org.knime.python2.kernel.PythonKernelQueue$KeyedPooledPythonKernelFactory.makeObject(PythonKernelQueue.java:1)

at org.apache.commons.pool2.impl.GenericKeyedObjectPool.create(GenericKeyedObjectPool.java:1051)

at org.apache.commons.pool2.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:347)

at org.apache.commons.pool2.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:270)

at org.knime.python2.kernel.PythonKernelQueue.dequeueHolder(PythonKernelQueue.java:298)

at org.knime.python2.kernel.PythonKernelQueue.getNextKernelInternal(PythonKernelQueue.java:282)

at org.knime.python2.kernel.PythonKernelQueue.getNextKernel(PythonKernelQueue.java:198)

at org.knime.python3.scripting.nodes.AbstractPythonScriptingNodeModel.getNextKernelFromQueue(AbstractPythonScriptingNodeModel.java:349)

at org.knime.python3.scripting.nodes.AbstractPythonScriptingNodeModel.execute(AbstractPythonScriptingNodeModel.java:214)

at org.knime.core.node.NodeModel.executeModel(NodeModel.java:549)

at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1267)

at org.knime.core.node.Node.execute(Node.java:1041)

at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:595)

at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:98)

at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:201)

at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:117)

at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:367)

at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:221)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)

at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)

Caused by: java.io.IOException: Cannot run program “/Users/guzhongqian/opt/anaconda3/envs/py3_knime/bin/python”: error=2, No such file or directory

at java.base/java.lang.ProcessBuilder.start(Unknown Source)

at java.base/java.lang.ProcessBuilder.start(Unknown Source)

at org.knime.python3.DefaultPythonGateway.(DefaultPythonGateway.java:176)

at org.knime.python3.DefaultPythonGateway.create(DefaultPythonGateway.java:144)

at org.knime.python3.scripting.Python3KernelBackend.(Python3KernelBackend.java:289)

at org.knime.python3.scripting.Python3KernelBackend.(Python3KernelBackend.java:240)

at org.knime.python3.scripting.Python3KernelBackendFactory.createBackend(Python3KernelBackendFactory.java:70)

at org.knime.python2.kernel.PythonKernelQueue$KeyedPooledPythonKernelFactory.createKernel(PythonKernelQueue.java:407)

… 24 more

Caused by: java.io.IOException: error=2, No such file or directory

at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)

at java.base/java.lang.ProcessImpl.(Unknown Source)

at java.base/java.lang.ProcessImpl.start(Unknown Source)

… 32 more

Did you get that specific error log before? Because that seems to be not the same, but a different issue now.
In your log, we see
Caused by: java.io.IOException: Cannot run program “/Users/guzhongqian/opt/anaconda3/envs/py3_knime/bin/python”: error=2, No such file or directory
Could you try in some terminal
conda activate /Users/guzhongqian/opt/anaconda3/envs/py3_knime
? Seems like this environment is not existing.

If it exists then please do
conda freeze
and post the content here.

Did you try my other suggestion (creating a new environment)?

1 Like

@eddy0620 maybe you can follow these instructions how to install the python extension for knime.

I tried to explain how the conda environment business works here:

KNIME and Python — Setting up and managing Conda environments

Hi, Steffen
After I re-creating new environment twice, fixed this issue.
Thank you very much.

2 Likes

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