I want to use the emoji library to replace emoji's in text, nothing fancy.
import os
import django
import emoji
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
django.setup()
test = "This is a teststring test test :-) "
message_without_emoji = emoji.demojize(test)
print(message_without_emoji)
When I run this code I get an error. I can't figure out why and how to correct this (never used django).
django.core.exceptions.ImproperlyConfigured: Requested setting EMOJI_IMG_TAG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I tried installing django (like suggested), but I still get the error. https://www.youtube.com/watch?v=2FvIa4BADvA
I don't understand why I should install django. In the documentation it isn't mentioned and the examples are straightforward. https://pypi.org/project/emoji/
==> Solution
I installed django-emoji and not the emoji library. I'm using PyCharm and in the menu "Show Context Actions" django-emoji was suggested as first in the list.
I did pip uninstall django-emoji and pip install emoji.
And now it works fine.