stephenmcd / django-socketio

WebSockets for Django
BSD 2-Clause "Simplified" License
1.32k stars 244 forks source link

No module named importlib #94

Closed chrisspen closed 8 years ago

chrisspen commented 8 years ago

When I went to initialize the sqlite database for the chat example with:

./manage.py migrate --run-syncdb

I received the error:

Traceback (most recent call last):
  File "./manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/management/base.py", line 398, in execute
    self.check()
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 10, in check_url_config
    return check_resolver(resolver)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 19, in check_resolver
    for pattern in resolver.url_patterns:
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/myproject/src/ros/ros_homebot_telepresence/src/urls.py", line 12, in <module>
    url("", include("django_socketio.urls")),
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django_socketio/urls.py", line 4, in <module>
    from django.utils.importlib import import_module
ImportError: No module named importlib

Is this a bug or did I misconfigure something?

The pip installation defaulted to Django 1.9. Does Django-socketio support this version?

chrisspen commented 8 years ago

Actually, it looks like this question was answered here and it seems Django 1.9 is not supported.

This answer shows how to fix this error in your code.

stephenmcd commented 8 years ago

Duplicate of #79

MikeSoft commented 8 years ago

@chrisspen I couldn't fix the issue, i would be grateful if you explain how you did it =)

chrisspen commented 8 years ago

@MikeSoft, What do you mean? All I did was copy and paste the snippet from that SO answer to fix the import. Django 1.9 removed backwards compatibility for some deprecated imports.

MikeSoft commented 8 years ago

@chrisspen i tried use the import fix, but It doesn't work to use this library =(

chrisspen commented 8 years ago

It's working for me. I merged a bunch of fixes in my own fork, which is currently in a pull request, but will likely not be merged for some time. Try that.

https://github.com/chrisspen/django-socketio