Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module name conflict in Python, how to resolve?

I came across a file in our project, called - wait for it - celery.py. Yes, and celery.py imports from the installed celery module (see http://www.celeryproject.org/) which is not an issue because the project's celery.py uses

from __future__ import absolute_import     

before importing from the installed celery module. Now, the problem comes from djcelery (django-celery) which also would like to import from celery (the installed one, not the project celery.py). This is where the clash comes because djcelery encounters the project's celery.py before it encounters the installed celery. How can I resolve this?

like image 889
pbhowmick Avatar asked Jan 05 '14 17:01

pbhowmick


1 Answers

The easiest and most sane way to do it is to refactor you project and change the name of the file.

There are probably some way strange way around this, but I would hardly consider that worth it, as it would most likely complicate your code, and make it prone to errors.

like image 60
Alexandru Chirila Avatar answered Oct 17 '22 05:10

Alexandru Chirila