Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Error running qcluster command Python 3.7 Django 2.1.5 #331

Closed
viperfx opened this issue Jan 19, 2019 · 17 comments
Closed

Import Error running qcluster command Python 3.7 Django 2.1.5 #331

viperfx opened this issue Jan 19, 2019 · 17 comments

Comments

@viperfx
Copy link

viperfx commented Jan 19, 2019

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "ENV/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "ENV/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "ENV/lib/python3.7/site-packages/django/core/management/__init__.py", line 224, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "ENV/lib/python3.7/site-packages/django/core/management/__init__.py", line 36, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "ENV/versions/3.7.0/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 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 "ENV/lib/python3.7/site-packages/django_q/management/commands/qcluster.py", line 4, in <module>
    from django_q.cluster import Cluster
  File "ENV/lib/python3.7/site-packages/django_q/cluster.py", line 24, in <module>
    from django_q import tasks
  File "ENV/lib/python3.7/site-packages/django_q/tasks.py", line 12, in <module>
    from django_q.cluster import worker, monitor
ImportError: cannot import name 'worker' from 'django_q.cluster' (ENV/lib/python3.7/site-packages/django_q/cluster.py)
Sentry is attempting to send 1 pending error messages
Waiting up to 10 seconds
Press Ctrl-C to quit
@Koed00
Copy link
Owner

Koed00 commented Jan 21, 2019 via email

@theunraveler
Copy link
Contributor

I'm running in to this also on python 3.6.4 and Django 1.11.18.

@theunraveler
Copy link
Contributor

theunraveler commented Jan 31, 2019

Looks to me like a circular import:

File "{ENV}/lib/python3.6/site-packages/django_q/cluster.py", line 24, in <module>
    from django_q import tasks
File "{ENV}/lib/python3.6/site-packages/django_q/tasks.py", line 12, in <module>
    from django_q.cluster import worker, monitor

@Koed00
Copy link
Owner

Koed00 commented Feb 11, 2019

@viperfx could it have been that you were running Django 1.11?

@theunraveler
Copy link
Contributor

Is this a known issue on Django 1.11?

@codeSamuraii
Copy link

codeSamuraii commented Feb 26, 2019

I'm running into this issue as well...
Tried with Python 3.6.8 and 3.7.2.

Django 2.1.7 - Django-q 1.0.1

@yannbu
Copy link

yannbu commented Feb 26, 2019

+1

Django-q 1.0.1
Django 2.1.4
Python 3.6.0

Happens when directly initiating a cluster in my code (not using the management command)

@codeSamuraii
Copy link

codeSamuraii commented Feb 26, 2019

I have a temporary fix.

In django_q/tasks.py, replace the line :

from django_q.cluster import worker, monitor

by

from django_q.cluster import *

The manage.py qcluster command then works for me.

Submitted a pull request with the modification (#343).

EDIT: See PR #356 for a better solution.

@telenieko
Copy link

Same with Django 2.1.7, django-q 1.0.1, python 3.6.8
Same with Django 2.1.5, django-q 1.0.1, python 3.6.8
Same with Django 2.1.0, django-q 1.0.1, python 3.6.8
Same with Django 2.1.0, django-q 1.0.0, python 3.6.8

@sato-s
Copy link

sato-s commented Mar 7, 2019

I have same issue.

Python 3.7.2,Django 2.1.5,django-q 1.0.1

@viperfx
Copy link
Author

viperfx commented Mar 13, 2019

@Koed00 I think it's worth reviewing this?

Seems to be a long list of people having this issue

@lamby
Copy link
Contributor

lamby commented Apr 25, 2019

Can reproduce here:

  • django.VERSION == (2, 2, 0, 'final', 0)
  • django-q version 1.0.1
  • sys.version is 3.7.2+ (default, Feb 2 2019, 14:31:48) \n[GCC 8.2.0]

@lamby
Copy link
Contributor

lamby commented Apr 26, 2019

Alternative PR created at #356

@grigory51
Copy link

Put your django_q app in INSTALLED_APPS after django.contrib.admin

@lamby
Copy link
Contributor

lamby commented May 7, 2019

I'm not using django.contrib.admin and am seeing this.

@joantune
Copy link

joantune commented May 31, 2019

Guys! - had the same issue with Python 3.7.0 - and Django 2.1.7

Solved it - the issue was that I didn't have django.contrib.admin in the INSTALLED_APPS - just make sure it's there and before django_q as @grigory51 pointed out
Cheers!

@lamby
Copy link
Contributor

lamby commented May 31, 2019

Perhaps, but that's not the real, ongoing solution. I mean, django-q should not require using the Django admin, at the very least, and the order of INSTALLED_APPS should not make any difference.

@Koed00 Koed00 closed this as completed in 5c82439 Aug 10, 2019
JereMalinen pushed a commit to JereMalinen/django-q that referenced this issue Aug 13, 2019
JereMalinen pushed a commit to JereMalinen/django-q that referenced this issue Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants