问题描述
尝试导入 hypothesis
时,其所在行出现错误:
from hypothesis import given,strategies as st
错误来自不同的库 attr
:
import attr
ModuleNotFoundError: No module named 'attr'
注意:我没有提到attr
;所以我假设 hypothesis
是 ;).
使用的终端安装包括:
pip install hypothesis
pip3 install hypothesis
pip install -r requirements.txt
requirements.txt 包含相关行:
hypothesis;
更新:pip install attrs
和 pip install attr
均无效(以及试用 pip3
并在 requirements.txt
中包含名称)
然而,它说 Requirement already satisfied:
解决方法
您以某种方式设法安装了 hypothesis
,而没有它的依赖项 attrs
(也许还有 sortedcontainers
)。
pip install hypothesis
也应该安装依赖项;所以这可能是你安装包的方式或 Python 环境的一个更普遍的问题。作为不能解决根本问题的解决方法,您可以
pip install hypothesis attrs sortedcontainers