I followed all steps to install Beautiful Soup, but it still comes out with this error:
AttributeError: module 'collections' has no attribute 'Callable'
I am using Python 3.10.
I followed all steps to install Beautiful Soup, but it still comes out with this error:
AttributeError: module 'collections' has no attribute 'Callable'
I am using Python 3.10.
collections.Callable
has been moved to collections.abc.Callable
in python 3.10+. A hacky solution is to add the reference back to collections
before importing the problem library.
import collections
collections.Callable = collections.abc.Callable
from bs4 import BeautifulSoup # for example
This solution worked for me:
Python310\Lib\site-packages\pyreadline
in your file browser.py3k_compat.py
in an text editor.isinstance(x, collections.Callable)
to return isinstance(x, collections.abc.Callable)
.I got the same AttributeError.
Then I looked inside the Python lib → collections folder. It has ABCs (abstract base classes) made separately in version 3.3 and above.
So resolve the error by opening /bs4/elements.py in an editor and replace collections.callable with collections.abc.callable. Hence the callable attribute can be easily accessed.
Change "%LOCALAPPDATA%\Programs\Python\Python310\Lib\site-ackages\pyreadline\py3k_compat.py" - 8th code as below: return isinstance(x, collections.abc.Callable)
You can uninstall the Python package pyreadline
and install pyreadline3
, which is an updated fork !
Beautiful Soup did not work with 3.10.
Reinstall with 3.9.
I was getting the same error while trying to run manticore, but apparently none of the answers were answering Mac users. So if you are on Mac and getting the same error, you have got to navigate to
lib/python3.10/site-packages/wasm/types.py Line 246
and change
isinstance(cur_field, collections.Callable)
to isinstance(cur_field, collections.abc.Callable)
I had Beautiful Soup in a folder within the same folder as the Python program, as opposed to "installing" it.
So in that folder, I opened element.py
and replaced all collections.Callable
with collections.abc.Callable
.
Python version 3.10.7
This error message indicates you have an old version of Beautiful Soup. The issue was already fixed back in Beautiful Soup 4.6.1, a release that came out in 2018. As of this writing, Beautiful Soup is up to version 4.11.1.
Update your Beautiful Soup, and the problem should be resolved.
instead of installing the zip folder of bs4, install it using your command prompt by typing: - pip install beautifulsoup4