httpwatcher
httpwatcher copied to clipboard
No longer works on Python >= 3.10 due to `MutableMapping` moving
When attempting to run httpwatcher
on Python >=3.10, you get the following error:
AttributeError: module 'collections' has no attribute 'MutableMapping'
This is because in Python3.10, MutableMapping
was moved from collections
to collections.abc
.
issue is in Tornado
how do i solve this?
@giovann997 change the import
from collections.abc import MutableMapping
or
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
from collections.abc import MutableMapping
else:
from collections import MutableMapping
In which file? I've changed '/home/user/.local/lib/python3.11/site-packages/tornado/httputil.py', but it didn't worked
I don't know for sure, because it could be in a venv. I assume the error message tells you where it is?
And make sure it is used correctly, something like
class HTTPHeaders(collections.MutableMapping)
or
....
# from collections.abc import MutableMapping
from collections import MutableMapping
class HTTPHeaders(MutableMapping)
File "/home/user/Documenti/GitHub/Thesis/serve.py", line 1, in <module>
from httpwatcher import HttpWatcherServer
File "/home/user/.local/lib/python3.11/site-packages/httpwatcher/__init__.py", line 4, i
n <module> from httpwatcher.server import *
File "/home/user/.local/lib/python3.11/site-packages/httpwatcher/server.py", line 13, in
<module> import tornado.web
File "/home/user/.local/lib/python3.11/site-packages/tornado/web.py", line 86, in <modul
e> from tornado import httputil
File "/home/user/.local/lib/python3.11/site-packages/tornado/httputil.py", line 111, in
<module> class HTTPHeaders(collections.MutableMapping):
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'MutableMapping'
I tried adding from collections import MutableMapping
before class HTTPHeaders(MutableMapping)
, but shows the same error
You can temporarily fix this by importing httpwatcher like this:
import collections.abc
collections.MutableMapping = collections.abc.MutableMapping
import httpwatcher
NOTE: The order is very important
~~Just updating tornado solves the issue for me~~
Actually, nvm, for some reason html is not auto-reloaded in browser