pandas库特定无法使用某些函数的问题

本文最后更新于:2024年5月18日 晚上

解决的问题AttributeError: partially initialized module ‘pandas’ has no attribute ‘read_json’ (most likely due to a circular import)

1
2
3
4
5
import pandas

df = pandas.read_json('Test/sites.json')

print(df.to_string())

在运行过程中遇到如下报错:

1
AttributeError: partially initialized module 'pandas' has no attribute 'read_json' (most likely due to a circular import)

解决方法:

检查其他模块的名称: 如果你有其他自定义模块或第三方模块的名称与pandas相似,可能会导致导入冲突。请确保没有其他模块干扰pandas的导入。如此处我命名该文件为json.py,即干扰了函数read_joson的使用。

其他函数如read_csv也适用。


pandas库特定无法使用某些函数的问题
https://furthur509.github.io/2024/05/18/解决read_json失效问题/
作者
Yang Mingxin
发布于
2024年5月18日
许可协议