Setting up the KNIME Python extension on Windows with Anaconda Installed

Hello,

I need some technical guidance on editing a .BAT file to fully integrate the Python Extension for Anaconda.

I followed the directions here:[https://www.knime.com/blog/setting-up-the-knime-python-extension-revisited-for-python-30-and-20]

But, I am stuck at the step "In order to use this new Python environment from inside of KNIME, you need to create a script (shell script on linux and the Mac, bat file on Windows) to launch it.

I made my BAT file; it looks like this:

@REM Adapt the directory in the PATH to your system
@SET PATH=C:\Users\richardsona4\anaconda;%PATH%
@CALL activate py35_knime || ECHO Activating py35_knime failed
@python %*

However, I keep getting an error in KNIME after linking to my .BAT file about "making sure to add path of the directory to that contains conda’s ‘activate’ command PATH. Isn’t this what I stated above? I’m lost here - I’d wish the directions could be a little more clearer.

Any help would be appreciated, thanks.

-Anthony

Hi Anthony,

I think the activate command is in “…\anaconda\Scripts” (at least the blog post says so, on my Linux machine it is in a subfolder “bin”). Can you please check that and if so, adjust your bat file accordingly and try again?
If that’s not the case or doesn’t solve the problem, can you please check whether there are any more descriptive error messages in your knime.log? (You can also just upload the entire log and I’ll check it.) Thanks!

Marcel

Thanks for your reply @MarcelW. Yes, I overlooked the “script” part of the directions. But I made this change to my .BAT file and I’m still having an issue:

@REM Adapt the directory in the PATH to your system
@SET PATH=C:\Users\richardsona4.anaconda\navigator\scripts;%PATH%
@CALL activate py35_knime || ECHO Activating py35_knime failed
@python %*

Below are my logs from this AM:

2018-11-09 08:49:00,285 : DEBUG : Thread-81 : PythonKernelTester : : : Error occurred during testing Python2 installation
2018-11-09 08:49:00,285 : DEBUG : Thread-81 : PythonKernelTester : : : Executed command: python C:\Program Files\KNIME\plugins\org.knime.python2_3.6.2.v201811051558\py\PythonKernelTester.py 2.7.0Could not find python executable at the given location: python.
2018-11-09 08:49:00,362 : DEBUG : Thread-82 : PythonKernelTester : : : Error occurred during testing Python3 installation
2018-11-09 08:49:00,362 : DEBUG : Thread-82 : PythonKernelTester : : : Executed command: C:\Users\richardsona4\py35.bat C:\Program Files\KNIME\plugins\org.knime.python2_3.6.2.v201811051558\py\PythonKernelTester.py 3.0.0
PYTHONPATH=:
PATH=:
Error during execution: ‘activate’ is not recognized as an internal or external command,
operable program or batch file.
‘python’ is not recognized as an internal or external command,
operable program or batch file.

Raw test output:
Activating py35_knime failed

2018-11-09 08:49:13,745 : DEBUG : Thread-83 : PythonKernelTester : : : Error occurred during testing Python2 installation
2018-11-09 08:49:13,745 : DEBUG : Thread-83 : PythonKernelTester : : : Executed command: python C:\Program Files\KNIME\plugins\org.knime.python2_3.6.2.v201811051558\py\PythonKernelTester.py 2.7.0Could not find python executable at the given location: python.
2018-11-09 08:49:13,799 : DEBUG : Thread-84 : PythonKernelTester : : : Error occurred during testing Python3 installation
2018-11-09 08:49:13,799 : DEBUG : Thread-84 : PythonKernelTester : : : Executed command: C:\Users\richardsona4\py35.bat C:\Program Files\KNIME\plugins\org.knime.python2_3.6.2.v201811051558\py\PythonKernelTester.py 3.0.0
PYTHONPATH=:
PATH=:
Error during execution: ‘activate’ is not recognized as an internal or external command,
operable program or batch file.
‘python’ is not recognized as an internal or external command,
operable program or batch file.

Raw test output:
Activating py35_knime failed

Hi @MarcelW - Any chance you have determined the error from my log? Thanks.

Can you try capital-case “Scripts”?

Thanks @christian.dietz - I tried that…still no luck…this is my latest script and error log.

@REM Adapt the directory in the PATH to your system
@SET PATH=C:\Users\richardsona4.anaconda\navigator\Scripts;%PATH%
@CALL activate py35_knime || ECHO Activating py35_knime failed
@python %*

2018-11-12 11:51:58,133 : DEBUG : KNIME-Worker-4 : Node : DL Python Network Creator : 0:2 : reset
2018-11-12 11:51:58,134 : ERROR : KNIME-Worker-4 : Node : DL Python Network Creator : 0:2 : Execute failed: Could not start Python kernel. Error during Python installation test: ‘activate’ is not recognized as an internal or external command,
operable program or batch file.
‘python’ is not recognized as an internal or external command,
operable program or batch file.

Please make sure to add the path of the directory that contains conda’s ‘activate’ command to PATH
as described in the Python 2 and Python 3 setup guide that can be found on the KNIME website.
Also make sure that the path to that directory is absolute, not relative… See log for details.
2018-11-12 11:51:58,141 : DEBUG : KNIME-Worker-4 : Node : DL Python Network Creator : 0:2 : Execute failed: Could not start Python kernel. Error during Python installation test: ‘activate’ is not recognized as an internal or external command,
operable program or batch file.
‘python’ is not recognized as an internal or external command,
operable program or batch file.

Please make sure to add the path of the directory that contains conda’s ‘activate’ command to PATH
as described in the Python 2 and Python 3 setup guide that can be found on the KNIME website.
Also make sure that the path to that directory is absolute, not relative… See log for details.
org.knime.python2.kernel.PythonIOException: Could not start Python kernel. Error during Python installation test: ‘activate’ is not recognized as an internal or external command,
operable program or batch file.
‘python’ is not recognized as an internal or external command,
operable program or batch file.

Please make sure to add the path of the directory that contains conda’s ‘activate’ command to PATH
as described in the Python 2 and Python 3 setup guide that can be found on the KNIME website.
Also make sure that the path to that directory is absolute, not relative… See log for details.
at org.knime.python2.kernel.PythonKernel.testInstallation(PythonKernel.java:348)
at org.knime.python2.kernel.PythonKernel.(PythonKernel.java:223)
at org.knime.dl.python.base.node.creator.DLPythonCreatorNodeModel.execute(DLPythonCreatorNodeModel.java:122)
at org.knime.core.node.NodeModel.executeModel(NodeModel.java:567)
at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1177)
at org.knime.core.node.Node.execute(Node.java:964)
at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:561)
at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:95)
at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:179)
at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:110)
at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:328)
at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:204)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)
2018-11-12 11:51:58,147 : DEBUG : KNIME-Worker-4 : WorkflowManager : DL Python Network Creator : 0:2 : DL Python Network Creator 0:2 doBeforePostExecution
2018-11-12 11:51:58,148 : DEBUG : KNIME-Worker-4 : NodeContainer : DL Python Network Creator : 0:2 : DL Python Network Creator 0:2 has new state: POSTEXECUTE
2018-11-12 11:51:58,150 : DEBUG : KNIME-Worker-4 : WorkflowManager : DL Python Network Creator : 0:2 : DL Python Network Creator 0:2 doAfterExecute - failure
2018-11-12 11:51:58,150 : DEBUG : KNIME-Worker-4 : Node : DL Python Network Creator : 0:2 : reset
2018-11-12 11:51:58,150 : DEBUG : KNIME-Worker-4 : Node : DL Python Network Creator : 0:2 : clean output ports.
2018-11-12 11:51:58,150 : DEBUG : KNIME-Worker-4 : WorkflowFileStoreHandlerRepository : DL Python Network Creator : 0:2 : Removing handler 681698ff-d087-48d0-96c9-87c893000121 (DL Python Network Creator 0:2: ) - 0 remaining
2018-11-12 11:51:58,151 : DEBUG : KNIME-Worker-4 : NodeContainer : DL Python Network Creator : 0:2 : DL Python Network Creator 0:2 has new state: IDLE
2018-11-12 11:51:58,153 : DEBUG : KNIME-Worker-4 : Node : DL Python Network Creator : 0:2 : Configure succeeded. (DL Python Network Creator)
2018-11-12 11:51:58,153 : DEBUG : KNIME-Worker-4 : NodeContainer : DL Python Network Creator : 0:2 : DL Python Network Creator 0:2 has new state: CONFIGURED
2018-11-12 11:51:58,154 : DEBUG : KNIME-Worker-4 : NodeContainer : DL Python Network Creator : 0:2 : TransferLearning (1).knwf 0 has new state: IDLE
2018-11-12 11:51:58,154 : DEBUG : KNIME-WFM-Parent-Notifier : NodeContainer : : : ROOT has new state: IDLE
2018-11-12 11:51:58,192 : DEBUG : KNIME-Node-Usage-Writer : NodeTimer$GlobalNodeStats : : : Successfully wrote node usage stats to file: C:\Users\richardsona4\Documents\MEGA\Main Folder\KNIME Workspace.metadata\knime\nodeusage_3.0.json
2018-11-12 11:52:04,697 : DEBUG : KNIME-Node-Usage-Writer : NodeTimer$GlobalNodeStats : : : Successfully wrote node usage stats to file: C:\Users\richardsona4\Documents\MEGA\Main Folder\KNIME Workspace.metadata\knime\nodeusage_3.0.json
2018-11-12 11:52:05,170 : DEBUG : KNIME-Node-Usage-Sender : NodeTimer$GlobalNodeStats : : : Successfully sent node usage stats to server

richardson4\anaconda?

Are you 100% sure that C:\Users\richardsona4.anaconda\navigator\Scripts is pointing on a conda directory?

Hi @christian.dietz,

Yes, this is a screenshot of the directory. Am I in the right conda directory?

Actually, no :-). Where is you anaconda installed? You defined the path during the installation process of anaconda, e.g.

2 Likes

Conda is installed at the following:

C:\Users\richardsona4\AppData\Local\Continuum\anaconda2

Scripts is located at: C:\Users\richardsona4\AppData\Local\Continuum\anaconda2\Scripts

I will update my BAT file and try again.

THank you @christian.dietz - you solved the problem - Python is now recognized!!! Thanks for being patient.

1 Like

Very cool. No problem at all. Have fun with the Python integration :slight_smile:

3 Likes

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