5

I need to use the django-emoji and the emoji library in a single Django project. Both installed via pip. Both of these libraries get imported from a package named emoji:

When importing from django-emoji:

from emoji import Emoji

When importing from emoji:

from emoji.core import get_emoji_regexp

Any idea how to rename the package a library installs to and yet still have it installed via pip?

Krystian Cybulski
  • 10,789
  • 12
  • 67
  • 98
  • Duplicate of http://stackoverflow.com/questions/5937739/python-module-name-conflict. Unfortunately no real answer over there. – kennytm Jan 27 '17 at 15:55
  • Saw the lack of answer there after I asked this question. Does this mean that there is no answer? That would be a sad hole in the python tooling. – Krystian Cybulski Jan 27 '17 at 15:56
  • Well which Python version are you using? – kennytm Jan 27 '17 at 16:11
  • I am using python 2.7.12. – Krystian Cybulski Jan 27 '17 at 16:32
  • So far I see that there is no way to do this. The theory is that packages on PyPI should be installed into unique top-level directories. This is violated in some cases. The solution is either to modify one of the conflicting packages or add an option to `pip` to support an override. – Krystian Cybulski Jan 27 '17 at 16:34

1 Answers1

-1
import emoji as django_emoji
django_emoji.Emoji

Wouldn't that work, or am I missing something?

Nether
  • 1,081
  • 10
  • 14
  • That does not work because I installed the `emoji` package after `django-emoji`. Now when I try to import from `emoji`, it only sees the `emoji` package. `django-emoji` is effectively invisible. I don't ave an issue with what the package ends up being called after I import it into my code. The issue is that the python import mechanism cannot access both of these packages, as both are known as `emoji`. – Krystian Cybulski Jan 27 '17 at 15:54