0

I am trying to run my local server for my website in Django but I can’t because I see the following errors `

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\management\__init__.py", line 398, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\registry.py", line 116, in populate
    app_config.import_models()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\apps\config.py", line 304, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\User\Official website\agent\agency\models.py", line 2, in <module>
    from socketserver import ThreadingUnixStreamServer
ImportError: cannot import name 'ThreadingUnixStreamServer' from 'socketserver' (C:\Users\User\AppData\Local\Programs\Python\Python310\lib\socketserver.py)

`

I tried; Restarting my pc. Closing command prompt and reopening it. Closing visual studio code

But nothing worked.

  • The `socketserver` module does not appear to contain anything named `ThreadingUnixStreamServer` - there are similar names, but not that exact name. I have no idea why you'd expect that name to work on a Windows computer, anyway. – jasonharper Nov 18 '22 at 19:01
  • The `socketserver` [documentation](https://docs.python.org/3/library/socketserver.html) clearly doesn't show anything called `ThreadingUnixStreamServer`, why do you think it should exist? – Random Davis Nov 18 '22 at 19:02
  • Looks like you have to actually be on a Unix-like system for that to even be available - the function seems to only exist if `hasattr(socket, "AF_UNIX")` is `True`, in the source code: https://github.com/python/cpython/blob/ecfff63e06e77e22035a7f7caa26986f033f3aea/Lib/socketserver.py#L140 But obviously you're on Windows, not Linux or Unix.... – Random Davis Nov 18 '22 at 19:05

0 Answers0