如何阻止VSCode在新项目中生成.hypothesis/unicode_data/13.0.0/charmap.json.gz?
解决运行Python代码时自动生成.hypothesis缓存目录的问题
问题根源
.hypothesis/unicode_data/... 是Hypothesis(一款Python测试库)的缓存文件,哪怕你没直接在代码里调用它,也可能被已安装的其他依赖(比如pandas、numpy等)间接引入。卸载Pydantic没用,说明它不是触发Hypothesis的源头。
解决方法
检查并卸载Hypothesis
先确认它是否已安装:pip list | grep hypothesis如果存在,直接卸载即可:
pip uninstall -y hypothesis你的代码仅用于数据爬取和处理,完全不需要测试库Hypothesis,卸载后不会影响代码正常运行。
禁用Hypothesis缓存(无需卸载的情况)
若需要保留Hypothesis,可通过以下方式阻止缓存生成:- 单次运行临时禁用
在VSCode终端先设置环境变量,再运行代码:export HYPOTHESIS_DONT_WRITE_CACHE=1 python your_script.py - 全局永久禁用
在用户根目录下创建.hypothesis/config文件,写入:[hypothesis] dont_write_cache = true - 代码内配置禁用
在你的Python脚本开头添加:from hypothesis import settings settings.register_profile("no_cache", dont_write_cache=True) settings.load_profile("no_cache")
- 单次运行临时禁用
验证
重新运行代码后,检查是否还会生成.hypothesis目录,问题即可解决。
内容的提问来源于stack exchange,提问作者Kikeshi
相关产品推荐
相关产品推荐

