How to create a .rar file using python?

Mudits picture Mudits · Jul 7, 2015 · Viewed 7.2k times · Source

I want to create a .rar file by passing file paths of the files to be archived.

I have tried the rarfile package. But it doesn't have a 'w' option to write to the rarfile handler.

Is there any other way?

Answer

Daniel Renshaw picture Daniel Renshaw · Jul 7, 2015

How about lib-rar-python?

It's a Python wrapper around the command line rar program, but it may be limited to Linux only.

On other platforms you could just call the command line rar program directly using Python's subprocess library.