0

I'm trying to learn Django channels, so for the beginning, I simply installed and added "channels" to the Django project, INSTALLED_APPS in the settings.py, as showing below.

Installed channels with pip:

pip install channels

Installed versions:

channels             3.0.3
daphne               3.0.1
Django               2.2.13

settings.py > INSTALLED_APPS:

INSTALLED_APPS = [

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',

        ...

    'django_ace',
    'channels', # added this
]

I just installed one package and added one line to the settings.py so this shouldn't be an error, but when I try to run the server python .\source\manage.py runserver I got an error as showing below.

> python .\source\manage.py runserver --noreload
Traceback (most recent call last):
  File ".\source\manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    django.setup()
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\apps\registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\django\apps\config.py", line 116, in create
    mod = import_module(mod_path)
  File "c:\python37\lib\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 "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\channels\apps.py", line 4, in <module>
    import daphne.server
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\daphne\server.py", line 32, in <module>
    from .ws_protocol import WebSocketFactory
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\daphne\ws_protocol.py", line 6, in <module>
    from autobahn.twisted.websocket import (
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\autobahn\twisted\__init__.py", line 40, in <module>
    from autobahn.twisted.websocket import \
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\autobahn\twisted\websocket.py", line 42, in <module>
    from autobahn.util import public
  File "C:\pg\django\win\simple-django-login-and-register\venv\lib\site-packages\autobahn\util.py", line 464, in <module>
    _ = _rtime()  # this starts wallclock
DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead

I did google and seems it's not version compatibility issue between django and channels, what's wrong with my project?

(added)

I tried pip install pypiwin32 seeing Error after adding Django channels to installed_apps in settings file - Stack Overflow, but it didn't solve anything, and stil the same error.

ー PupSoZeyDe ー
  • 1,082
  • 3
  • 14
  • 33
  • which `python version` are you using ? – Lars Feb 14 '21 at 07:04
  • it's Python 3.7.6 – ー PupSoZeyDe ー Feb 14 '21 at 07:23
  • @pupsozeyde Did you follow the instructions here [https://channels.readthedocs.io/en/stable/installation.html](https://channels.readthedocs.io/en/stable/installation.html)? It seems like you only installed the package and added it to INSTALLED_APPS. You also need to change the `asgi.py` file and set `ASGI_APPLICATION` in your settings – Abdul Aziz Barkat Feb 14 '21 at 07:38
  • @AbdulAzizBarkat yes, I also tried that as the instruction but it didn't work, as the same error. – ー PupSoZeyDe ー Feb 14 '21 at 07:55
  • @pupsozeyde looks like a problem with autobahn-python. check this [issue](https://github.com/crossbario/autobahn-python/issues/1308). For some reason they only use the suggested replacement function only if python version >= 3.8 even though the previous function was deprecated since 3.3. Does the warning stop execution or it continues executing? One solution would be to update to python >= 3.8 – Abdul Aziz Barkat Feb 14 '21 at 08:18
  • @pupsozeyde- I am not sure why you are getting this error. I just did a fresh install of channels with the following versions aioredis==1.3.1 asgiref==3.3.1 async-timeout==3.0.1 attrs==20.3.0 autobahn==21.2.1 Automat==20.2.0 certifi==2020.12.5 cffi==1.14.5 channels==3.0.3 channels-redis==3.2.0 chardet==4.0.0 constantly==15.1.0 cryptography==3.4.5 daphne==3.0.1 Django==3.1.6 django-channels==0.7.0 hiredis==1.1.0 hyperlink==21.0.0 idna==2.10 incremental==17.5.0 msgpack==1.0.2 oauthlib==3.1.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycparser==2.20 PyHamcrest==2.0.2 pyOpenSSL==20.0.1 pytz==2021.1 requ – SDRJ Feb 14 '21 at 07:23

0 Answers0