gpt4 book ai didi

python - functools 没有属性 lru_cache

转载 作者:行者123 更新时间:2023-12-03 19:31:45 45 4
gpt4 key购买 nike

我在 Windows 上使用 Python 3.7
运行每个代码时都会发生此错误:

Traceback (most recent call last):
File "test.py", line 1, in <module>
import nltk
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\nltk\__init__.py", line 99, in <module>
from nltk.internals import config_java
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\nltk\internals.py", line 11, in <module>
import subprocess
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 50, in <module>
import signal
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\signal.py", line 3, in <module>
from functools import wraps as _wraps
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\functools.py", line 21, in <module>
from collections import namedtuple
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\collections\__init__.py", line 22, in <module>
from keyword import iskeyword as _iskeyword
File "C:\Users\HP\Desktop\tweepy\keyword.py", line 1, in <module>
import re
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\re.py", line 297, in <module>
@functools.lru_cache(_MAXCACHE)
AttributeError: module 'functools' has no attribute 'lru_cache'
如何解决?

最佳答案

好像有人发表了 functools在 pypi 上打包,所以如果你运行了:

# don't run this!
pip install functools
您可能不小心安装了该软件包。如果您遇到此错误,我会:
pip uninstall functools
确保您使用的 functools 是基础包 functools。
(我在这里结束是因为我试图使用 functools.cache ,它似乎只存在于 Python 3.8 中,而不是更早的版本。)

关于python - functools 没有属性 lru_cache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53775792/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com