情况说明
今天在装live server时遇到如下两个问题。
- module ‘collections’ has no attribute ‘MutableSet’
- AttributeError: module ‘collections’ has no attribute ‘MutableMapping’
部分错误结果如下:
(py3_django4-0-4) lds@lishuaige:~/Desktop/meiduo/front_end$ live-server
Traceback (most recent call last):
File "/home/lds/.local/bin/live-server", line 5, in <module>
from live_server.cli import cli
File "/home/lds/.local/lib/python3.10/site-packages/live_server/cli.py", line 4, in <module>
from . import watcher
File "/home/lds/.local/lib/python3.10/site-packages/live_server/watcher.py", line 7, in <module>
from . import server
File "/home/lds/.local/lib/python3.10/site-packages/live_server/server.py", line 5, in <module>
import tornado.web
File "/home/lds/.local/lib/python3.10/site-packages/tornado/web.py", line 88, in <module>
from tornado import httputil
File "/home/lds/.local/lib/python3.10/site-packages/tornado/httputil.py", line 107, in <module>
class HTTPHeaders(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
解决方案
网上找了好多都是把问题贴出来然后就没下文了,琢磨了三四个小时幸亏解决了!!应该是python 3.10 那些 MutableMapping,MutableSet等放的位置变了,他们的上级模块原本直属collections的变成了abc,也就是说,需要把
collections.MutableMapping
改成
collections.abc.MutableMapping
那要怎么改呢?文章来源:https://www.toymoban.com/news/detail-538347.html
比如我这里报错,就点进源文件里面
按上述方法修改即可。
文章来源地址https://www.toymoban.com/news/detail-538347.html
到了这里,关于AttributeError: module ‘collections‘ has no attribute ‘MutableMapping‘的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!