"mercury run demo" results in "ImportError: cannot import name 'Celery' from 'celery' "
soichih opened this issue · comments
Soichi Hayashi commented
Hello. I just install mercury (v2.2.7) on my python 3.7.4 pyenv.
When I run "mercury run demo", I get the following error message.
$ mercury run demo
_ __ ___ ___ _ __ ___ _ _ _ __ _ _
| '_ ` _ \ / _ \ '__/ __| | | | '__| | | |
| | | | | | __/ | | (__| |_| | | | |_| |
|_| |_| |_|\___|_| \___|\__,_|_| \__, |
__/ |
|___/
Traceback (most recent call last):
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/core/management/base.py", line 86, in wrapped
saved_locale = translation.get_language()
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/utils/translation/__init__.py", line 254, in get_language
return _trans.get_language()
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/utils/translation/__init__.py", line 57, in __getattr__
if settings.USE_I18N:
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/mercury/server/__init__.py", line 1, in <module>
from .celery import app as celery_app
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/mercury/server/celery.py", line 5, in <module>
from celery import Celery
ImportError: cannot import name 'Celery' from 'celery' (/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/celery/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/local/shayashi/git/investment/webdata/pyenv/bin/mercury", line 8, in <module>
sys.exit(main())
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/mercury/mercury.py", line 117, in main
execute_from_command_line(["mercury.py", "migrate", "-v", 0])
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/core/management/base.py", line 367, in run_from_argv
connections.close_all()
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/db/utils.py", line 208, in close_all
for alias in self:
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/utils/connection.py", line 73, in __iter__
return iter(self.settings)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/utils/connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/db/utils.py", line 144, in configure_settings
databases = super().configure_settings(databases)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/utils/connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/mercury/server/__init__.py", line 1, in <module>
from .celery import app as celery_app
File "/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/mercury/server/celery.py", line 5, in <module>
from celery import Celery
ImportError: cannot import name 'Celery' from 'celery' (/local/shayashi/git/investment/webdata/pyenv/lib/python3.7/site-packages/celery/__init__.py)
Soichi Hayashi commented
I tried it on newer pyenv with python 3.11. pip ends up installing slightly newer version of mercury (2.3.4). With this version, I no longer see the error message. All seems to be well so far.