2

I'm following this tutorial to experiment Channels with Django. I'm working on Windows 10 HOME, Django 2.1.4 and Python 3.7.1

The goal of this tutorial is to build a chat app.

After downloading chromeDriver and adding it in the PATH, I run this command in my prompt :

py manage.py test chat.tests

Which returns this error message :

EETraceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

======================================================================
ERROR: test_when_chat_message_posted_then_not_seen_by_anyone_in_different_room (chat.tests.ChatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\test\testcases.py", line 202, in __call__
    self._pre_setup()
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
    self._server_process.start()
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\reduction.py", line 61, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'DaphneProcess.__init__.<locals>.<lambda>'

======================================================================
ERROR: test_when_chat_message_posted_then_seen_by_everyone_in_same_room (chat.tests.ChatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\test\testcases.py", line 202, in __call__
    self._pre_setup()
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
    self._server_process.start()
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\reduction.py", line 61, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'DaphneProcess.__init__.<locals>.<lambda>'

----------------------------------------------------------------------
Ran 0 tests in 4.689s

FAILED (errors=2)
Destroying test database for alias 'default'...

The same question (https://stackoverflow.com/questions/50016048....) provide a solution, but it doesn't work for me.

When I modify the file reduction.py to replace import pickle by import dill as pickle, I'm getting this new message error :

DevTools listening on ws://127.0.0.1:25037/devtools/browser/b4c722e4-c7f2-49fb-939b-7372e9688eea
C:\Users\kevin\Envs\myproject\lib\site-packages\daphne\server.py:13: UserWarning: Something has already installed a non-asyncio Twisted reactor. Attempting to uninstall it; you can fix this warning by importing daphne.server early in your codebase or finding the package that imports Twisted and importing it later on.
  UserWarning,
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "c:\users\kevin\appdata\local\programs\python\python37-32\Lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\dill\_dill.py", line 304, in load
    obj = pik.load()
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\dill\_dill.py", line 465, in find_class
    return StockUnpickler.find_class(self, module, name)
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\channels\auth.py", line 12, in <module>
    from django.contrib.auth.models import AnonymousUser
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\db\models\base.py", line 87, in __new__
    app_config = apps.get_containing_app_config(module)
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\apps\registry.py", line 249, in get_containing_app_config
    self.check_apps_ready()
  File "C:\Users\kevin\Envs\myproject\lib\site-packages\django\apps\registry.py", line 132, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Please, someone could bring me help ?

FrancNovation
  • 349
  • 6
  • 20
  • `django.core.exceptions.AppRegistryNotReady` suggests a miss configuration/lack of config. does the server run locally (not in test mode) with `Daphne`? Are you able to get this to work on a linux/posix system, the forking and rebuilding of python may be a little different. – Matthaus Woolard Jan 04 '19 at 01:18
  • Thanks again @MatthausWoolard, my server is running locally with DEBUG = True in my settings.py file. My OS is Windows 10 . What could I get round this issue ? – FrancNovation Jan 04 '19 at 10:59
  • do you still get this error when running in ubuntu? – Matthaus Woolard Jan 04 '19 at 11:42
  • I'm going to try and I'll tell you – FrancNovation Jan 04 '19 at 12:31
  • I had this exact same error, and I even opened up an issue on the GitHub page, but I was told to come here. Here is my post: https://stackoverflow.com/questions/54039839/channelsliveservertestcase-failing-with-error-while-following-django-channels-tu – Tyranno Taiwo Jan 05 '19 at 14:26
  • To try the solution of @MatthausWoolard. I'have tried to use Ubuntu through WSL. It took me few hours to make virtualenvwrapper and Django working... I will try tomorrow to get the next step : to setup XMING server on Windows, in order to use editor like SUBLIME through WSL to edit Django files. Without this, I would get file format conflicts if I run files from Ubuntu which would be edited from a Windows editor software. – FrancNovation Jan 07 '19 at 10:51
  • I personally have had very little luck using windows for this type of development work, if possible I would strongly suggest (assuming you are deploying in production on linux) to use a posix env (Linux or macOS) and connecting to windows (running in a vm/RDP) when needed. If (due to corporate hell) you can't set up a posix system I would suggest the next best thing being running a full VM (with UI) and doing all you server dev within that. – Matthaus Woolard Jan 08 '19 at 00:55
  • Thanks again @MatthausWoolard for your advise. Sorry, I'm not really a specialist about VM. Currently, I'm developing my web app from windows using VIRTUALENVWRAPPER. At the end, I'll load my web app on the DEBIAN OS. Could you give me your feeling and advise relative to this configuration ? Should I stop right now my development to change of development configuration ? Maybe I can create a new question about this subject. – FrancNovation Jan 08 '19 at 16:02
  • @FrancNovation if possible in your case I would look at installing Linux on your dev machine then (dual booting it) so that when you are working on your app you are fully in the POSIX world, in the long term this will (in my experience) be a much simpler dev env to work in. – Matthaus Woolard Jan 08 '19 at 16:33
  • @MatthausWoolard Ok thank you for your advises – FrancNovation Jan 09 '19 at 18:30

0 Answers0