ModulenotFoundError:无模块名为' '
我正在尝试运行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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,所以这个问题本质上是一个错字...
我在我的设置中有这个:py:
我不小心修复了
偶然删除后,一切正常,一切正常
Ok so the issue was essentially a typo...
I had this in my settings.py:
Which I accidentally changed to
After fixing my accidental delete, all is working fine