Runtime.ImportModuleError: Unable to import module 'main': cannot import name 'is_arabic' from

225 Views Asked by At

When I do: sam local invoke MyFunction --event events/my_event.json

I get this error: [ERROR] Runtime.ImportModuleError: Unable to import module 'main': cannot import name 'is_arabic' from 'charset_normalizer.utils' (/var/task/charset_normalizer/utils.py)

Sorry, I am not too familiar with the aws-sam, I have been just using a prior script and it was working fine. Any pointer would be much appreciated. Thank you!

1

There are 1 best solutions below

3
tikka On

Ok, after a lot of head-scratching, this helped.

In the requirements.txt I had requests==2.31.0 earlier. I changed that to requests==2.28.1 and now the [ERROR] ... Unable to import module 'main': cannot import name 'is_arabic' from 'charset_normalizer.utils' ... is gone.

I still do not get why this fixed the issue, because I think I had requests==2.31.0 earlier and I believe it had worked. However, going through the history of the requirements.txt (+ my notes), I had requests==2.28.1 much earlier. So I thought of going back to requests==2.28.1 and it helped.

Again, I do not understand why this fixed the issue. So if someone can shed some light that would be really helpful.

OR, if there is an alternative fix to this issue, kindly post.

Thank you!