could not find an executable program to extract format rar; candidates are (rar,unrar,7z),

Hi everyone,

I have a python code that works correctly but same code in the python snippet gets this error inside of the node(but not in the execution):

patool error: error extracting C:\Users\sajjad\Documents\knime-workspace.…\Rar Extraction\data\knimetemp-be29de03902b4eab\New folder.rar
could not find an executable program to extract format rar; candidates are (rar,unrar,7z),

p.s: for the python code I had to create a UNRAR_LIB_PATH variable in the system environment with the value of UnRAR64.dll. so, I guess that maybe knime has no access to the system environment?!

Best
Sajjad

Nobody knows the problem???

please help me

Can you post your Python code that you are using as well? We don’t have much to work with here.

Maybe you could try using the External Tool node to invoke WinRAR instead?

1 Like

hello @ScottF,
here is my python code:

import os, zipfile, pyunpack
basis_folder =  r'C:/Users/sajjad/Documents/knime-workspace/Rar Extraction/data/knimetemp-be29de03902b4eab/'

for root, dirs, files in os.walk(basis_folder):
    for filename in files:
        if filename.endswith(".rar") :
            print('RAR:'+os.path.join(root,filename))
        elif filename.endswith(".zip"):
            print('ZIP:'+os.path.join(root,filename))
        name = os.path.splitext(os.path.basename(filename))[0]
        if filename.endswith(".rar") or filename.endswith(".zip"):
            try:
                arch = pyunpack.Archive(os.path.join(root,filename))
                # os.mkdir(name)
                arch.extractall(directory=root)
                os.remove(os.path.join(root,filename))
            except Exception as e:
                print("ERROR: BAD ARCHIVE "+os.path.join(root,filename))
                print(e)
                try:
                    # os.path.join(root,filename)os.remove(filename)
                    pass
                except OSError as e: # this would be "except OSError, e:" before Python 2.6
                    if e.errno != errno.ENOENT: # errno.ENOENT = no such file or directory
                        raise # re-raise exception if a different error occurred   

Thanks I will check the external tool node.

I found the solution to this problem, for further issues that may come to anyone, here is the answer:

you should copy and paste the “UnRAR” file (which can be found in this path C:\Program Files (x86)\WinRAR) into the workflow folder in knime-workspace, in this scenario your python snippet can find the executable RAR file.

1 Like

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