Search code examples
pythoninstapy

Getting error "cannot import name 'UNICODE_EMOJI' from 'emoji.unicode_codes' "


I'm trying to create an Instagram bot using InstaPy. I'm following this tutorial.

When I ran:

from instapy import InstaPy

session = InstaPy(username="your username", password="your password")
session.login()

I got this error:

ImportError: cannot import name 'UNICODE_EMOJI' from 'emoji.unicode_codes' (C:\Users\roeegg22\AppData\Local\Programs\Python\Python310\lib\site-packages\emoji\unicode_codes\__init__.py)

I tried some solutions online, but none of them worked.


Solution

  • This happens because instapy (or some other library) doesn't reflect the latest update to the emoji library. You should be able to fix it by running

    pip uninstall emoji
    pip install emoji==1.7
    

    in the terminal. That way you install the version of emoji library that instapy is made around and the import should work.