I have a rar file, which I want to unrar in AWS lambda using python. I learned about unrar library in python. I have created the layer for unrar in AWS. But now when I execute the code
from unrar import rarfile
rar = rarfile.RarFile('file.rar')
rar.extractall()
I got the following error
Couldn't find path to unrar library.
I read the solution. According to the solution, I have to set the environment variable. can I use this solution for AWS Lambda also? and what other solutions can be possible.
Firstly, I followed documentation of unrar. Steps I followed
make lib && make install-liblibunrar.sofile at/usr/liblocation in linux.Python unrar could not find this file in Linux path, which is why It was throwing
Couldn't find path to unrar library.Now, I created a lambda layer for this file.
Finally, set an environment variable in lambda
UNRAR_LIB_PATHtolibunrar.so