ModuleNotFoundError:没有名为“pandas.core.indexes”的模块

新手上路,请多包涵

我编写了这段代码来将数据集加载到数据框中。数据集在 pickle 文件中给出,但会引发错误:

ModuleNotFoundError:没有名为“pandas.core.indexes”的模块

import pickle
import pandas
dbfile = open(dataset loction,'rb')
df = pickle.load(dbfile)

我尝试了所有给出的修复:

  1. 更新了熊猫
  2. 使用 df = pandas.read_picle(dataset location)

尝试使用 pip 安装 pickle 但出现此错误

C:\installs\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64>python -m pip install pickle
Collecting pickle
  Could not find a version that satisfies the requirement pickle (from versions: )
No matching distribution found for pickle

原文由 RAMAN BHATIA 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.6k
2 个回答

听起来 pickle 文件是用不同版本的 Pandas 创建的,而您当前安装的 Pandas 没有 pickle 中的某些数据所需的 pandas.core.indexes 模块。

您使用的是哪个版本的 Pandas?你试过升级吗?

编辑:Pandas 0.19.2 没有那个模块:

 $ pip install pandas==0.23.3
$ python
>>> import pandas.core.indexes as i
>>>
$ pip install pandas==0.19.2
$ python
>>> import pandas.core.indexes as i
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas.core.indexes'
>>>

原文由 AKX 发布,翻译遵循 CC BY-SA 4.0 许可协议

@AKX 的回答让我意识到这可能是 Pandas 的版本问题。但是,我只需要升级。

 pip install pandas --upgrade

原文由 ojunk 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进