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

no module 'chatbot_website.routing' #187

Open
wujiajia2017scnu opened this issue Apr 24, 2018 · 9 comments
Open

no module 'chatbot_website.routing' #187

wujiajia2017scnu opened this issue Apr 24, 2018 · 9 comments

Comments

@wujiajia2017scnu
Copy link

when i run: python3 manage.py runserver
it shows:
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'chatbot_website.routing'

how to solve it? 3ku

@crazysal
Copy link

crazysal commented May 2, 2018

Same error.

There is no file routing.py in chatbot_website/chatbot_website

So I changed line 73 of chatbot_website/chatbot_website/settings.py
from
ASGI_APPLICATION = 'chatbot_website.routing.application'
to
ASGI_APPLICATION = 'chatbot_interface.routing.application'

But then I realised django channels has updated to 2.0

And there is no backward compatibility for legacy version.

So this needs major refactoring to make channels 2 compatible.

traceback after above update :

  File "/home/sal/anaconda3/lib/python3.6/site-packages/channels/routing.py", line 33, in get_default_application
    module = importlib.import_module(path)
  File "/home/sal/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/media/sal/Repos/repos/chatty/DeepQA-master/chatbot_website/chatbot_interface/routing.py", line 1, in <module>
    from . import consumer
  File "/media/sal/Repos/repos/chatty/DeepQA-master/chatbot_website/chatbot_interface/consumer.py", line 1, in <module>
    from channels import Group
ImportError: cannot import name 'Group'

During handling of the above exception, another exception occurred:


  File "/home/sal/anaconda3/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/sal/anaconda3/lib/python3.6/site-packages/channels/management/commands/runserver.py", line 80, in inner_run
    application=self.get_application(options),
  File "/home/sal/anaconda3/lib/python3.6/site-packages/channels/management/commands/runserver.py", line 105, in get_application
    return StaticFilesWrapper(get_default_application())
  File "/home/sal/anaconda3/lib/python3.6/site-packages/channels/routing.py", line 35, in get_default_application
    raise ImproperlyConfigured("Cannot import ASGI_APPLICATION module %r" % path)
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'chatbot_interface.routing'

Because there is no Group in channel 2

@wujiajia2017scnu
Copy link
Author

thank you sir,you are right. when i uninstall channels==2.0, and install channels==1.1.6. and install django==1.10. The chatbot web is successful. So happy.
what's more,you should not to change the code of the project. like changing the code from
ASGI_APPLICATION = 'chatbot_website.routing.application'
to
ASGI_APPLICATION = 'chatbot_interface.routing.application'
that's all.

@Yorchbs
Copy link

Yorchbs commented May 29, 2018

Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute django.setup() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/config.py", line 120, in create mod = import_module(mod_path) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/Users/jorge/DeepQA-master/chatbot_website/chatbot_interface/chatbotmanager.py", line 11, in <module> from chatbot import chatbot ImportError: cannot import name 'chatbot'

I have this error and i dont know why

@dupanfei1
Copy link

channels=1.1.6
django==1.10.7
asgi-redis==1.4.3
可以

@crazysal
Copy link

run the docker image, that worked for me. or maybe port code to channels 2.

@Prskriti
Copy link

Prskriti commented Oct 8, 2018

I am also facing same issue but installing packages of above mentioned version didn't helped.
Please let me know if anyone know how to fix this error
This is what I am getting:
C:\Users\shaprakr\Desktop\Project\website>python manage.py runserver
Unhandled exception in thread started by <function check_errors..wrapper
at 0x0000003271FE1A60>
Traceback (most recent call last):
File "C:\Users\shaprakr\AppData\Local\Continuum\anaconda3\lib\site-packages\dj
ango\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\shaprakr\AppData\Local\Continuum\anaconda3\lib\site-packages\ch
annels\management\commands\runserver.py", line 45, in inner_run
self.server_cls = RunserverCommand.server_cls
AttributeError: type object 'Command' has no attribute 'server_cls'

@johnpaul89
Copy link

I'm also getting the same error.

System check identified no issues (0 silenced).
February 24, 2019 - 13:06:33
Django version 2.1.7, using settings 'messages.settings'
Starting ASGI/Channels version 2.1.7 development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Unhandled exception in thread started by <function check_errors..wrapper at 0x7fd12f3398c8>
Traceback (most recent call last):
File "/home/john/Projects/Django/Message_Channels/lib/python3.5/site-packages/channels/routing.py", line 33, in get_default_application
module = importlib.import_module(path)
File "/home/john/Projects/Django/Message_Channels/lib/python3.5/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 665, in exec_module
File "", line 222, in _call_with_frames_removed
File "/home/john/Projects/Django/Message_Channels/messages/routing.py", line 6, in
from chat.consumers import ChatConsumer
File "/home/john/Projects/Django/Message_Channels/chat/consumers.py", line 5, in
from channels.db import database_sync_to_sync
ImportError: cannot import name 'database_sync_to_sync'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/john/Projects/Django/Message_Channels/lib/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/john/Projects/Django/Message_Channels/lib/python3.5/site-packages/channels/management/commands/runserver.py", line 101, in inner_run
application=self.get_application(options),
File "/home/john/Projects/Django/Message_Channels/lib/python3.5/site-packages/channels/management/commands/runserver.py", line 126, in get_application
return StaticFilesWrapper(get_default_application())
File "/home/john/Projects/Django/Message_Channels/lib/python3.5/site-packages/channels/routing.py", line 35, in get_default_application
raise ImproperlyConfigured("Cannot import ASGI_APPLICATION module %r" % path)
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'messages.routing'

@levifeldman
Copy link

in channels/routing.py when it gets the default application in the first function it should really bubble back up the exception traceback from trying to import the ASGI_APPLICATION, instead of just saying improperly configured application because that is so vague it could mean there is a type in your consumers or a typo in one of your import statements in any of like three files anyway it would be really easy to just in that function's try and except to cathc the importlib.import_module exception (if there is) and bubble it back up to the interpreter.

@levifeldman
Copy link

until then if you want to find out why specifically ASGI_APPLICATION is improperly configured in manage.py shell, import importlib, then try importlib.import_module('whateverapp.routing.application')
you can see where specifically its erroring

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

7 participants