Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "AttributeError 'collections' has no attribute 'Callable' " using Beautiful Soup

I followed all steps to install Beautiful Soup, but it still comes out with this error:

AttributeError: module 'collections' has no attribute 'Callable'

Stacktrace

I am using Python 3.10.

like image 223
Tan20211010 Avatar asked Aug 30 '25 15:08

Tan20211010


2 Answers

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
like image 97
alinajafi Avatar answered Sep 15 '25 04:09

alinajafi


This solution worked for me:

  1. Navigate to Python310\Lib\site-packages\pyreadline in your file browser.
  2. Open py3k_compat.py in an text editor.
  3. Change the 8th line from which should be return isinstance(x, collections.Callable) to return isinstance(x, collections.abc.Callable).
  4. Save, exit and then retry.
like image 27
Ashen Frost Avatar answered Sep 15 '25 02:09

Ashen Frost