Daniel Johnson
Daniel Johnson

Reputation: 251

ModuleNotFoundError: No module named ' '

I am attempting to run python manage.py runserver and I am getting a

ModuleNotFoundError: No module named ' '

The entirety of the output can be seen here:

(venv) danieljohnson@MACHPXNV2CL2Y project % python manage.py runserver
/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/tzwhere/tzwhere.py:62: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  self.timezoneNamesToPolygons[tzname] = WRAP(polys)
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/channels/management/commands/runserver.py", line 51, in inner_run
    http_consumer=self.get_consumer(*args, **options),
  File "/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/channels/management/commands/runserver.py", line 157, in get_consumer
    return StaticFilesConsumer()
  File "/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/channels/handler.py", line 347, in __init__
    self.handler = self.handler_class()
  File "/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/channels/staticfiles.py", line 18, in __init__
    super(StaticFilesHandler, self).__init__()
  File "/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/channels/handler.py", line 194, in __init__
    self.load_middleware()
  File "/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 56, in load_middleware
    mw_class = import_string(middleware_path)
  File "/Users/danieljohnson/Documents/code/project/venv/lib/python3.9/site-packages/django/utils/module_loading.py", line 20, in import_string
    module = import_module(module_path)
  File "/opt/homebrew/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named ' '
2022-05-09T14:03:08Z <Greenlet at 0x146a6e7b0: wrapper(verbosity=1, settings=None, pythonpath=None, traceback=False, no_color=False, addrport=None, use_ipv6=False, use_threading=True, use_reloader=True, run_worker=True, use_asgi=True, http_timeout=60, websocket_handshake_timeout=5, use_static_handler=True, insecure_serving=False)> failed with ModuleNotFoundError

The module import code in /opt/homebrew/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py =

def import_module(name, package=None):
    """Import a module.

    The 'package' argument is required when performing a relative import. It
    specifies the package to use as the anchor point from which to resolve the
    relative import to an absolute import.

    """
    level = 0
    if name.startswith('.' or ' '):
        if not package:
            msg = ("the 'package' argument is required to perform a relative "
                   "import for {!r}")
            raise TypeError(msg.format(name))
        for character in name:
            if character != '.':
                break
            level += 1
    print(name)
    return _bootstrap._gcd_import(name[level:], package, level)

That print(name) statement prints out " .middleware"

I've tried installing/reinstalling gevent, but that didnt work. I'm lost because the package that is missing is blank. Any ideas?

Upvotes: 0

Views: 2349

Answers (1)

Daniel Johnson
Daniel Johnson

Reputation: 251

Ok so the issue was essentially a typo...

I had this in my settings.py:

"authentication.middleware.SetDefaultUserGroupMiddleware" if not API_MODE else None,

Which I accidentally changed to

" .middleware.SetDefaultUserGroupMiddleware" if not API_MODE else None,

After fixing my accidental delete, all is working fine

Upvotes: 0

Related Questions