File “C:\ProgramData\anaconda3\lib\site-packages\pyreadline\py3k_compat.py”, line 8, in callable
return isinstance(x, collections.Callable)
AttributeError: module ‘collections’ has no attribute ‘Callable’
参考 https://stackoverflow.com/questions/69515086/error-attributeerror-collections-has-no-attribute-callable-using-beautifu
更改文件 为
from __future__ import print_function, unicode_literals, absolute_import
import sys
if sys.version_info[0] >= 3:
import collections
collections.Callable = collections.abc.Callable
PY3 = True
def callable(x):
return isinstance(x, collections.Callable)
def execfile(fname, glob, loc=None):
loc = loc if (loc is not None) else glob
with open(fname) as fil:
txt = fil.read()
exec(compile(txt, fname, 'exec'), glob, loc)
unicode = str
bytes = bytes
from io import StringIO
else:
PY3 = False
callable = callable
execfile = execfile
bytes = str
unicode = unicode
from StringIO import StringIO
再运行示例就成功了
2023年12月5日