ModulenotFoundError:无模块名为' '

发布于 2025-01-27 18:05:59 字数 4675 浏览 2 评论 0原文

我正在尝试运行python manage.py runserver,我可以

ModuleNotFoundError: No module named ' '

在这里看到全部输出:

(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

在/opt/opt/opt/homebrew/cellar/ [email&nbsp; procearted] /3.9.9.12/frameworks/frameworks/python.frameworks/python.framework/vramework/versions/versions/3.9/3.9/lib/pypytynon33 .9/ementlib/ 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)

print(name)语句打印出“ .middleware”

我尝试安装/重新安装gevent,但这无效。我迷路了,因为缺少的包装是空白。有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开雨落又逢春i 2025-02-03 18:05:59

好的,所以这个问题本质上是一个错字...

我在我的设置中有这个:py:

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

我不小心修复了

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

偶然删除后,一切正常,一切正常

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文