熊猫导入:模块未找到错误:没有名为'pandas._libs.tslib'的模块

2024-07-05 10:23:28 发布

您现在位置:Python中文网/ 问答频道 /正文

每当我尝试导入熊猫时,无论是在virtualenv中还是在其他地方,我都会遇到这个错误。

Python 3.6.2 |Anaconda custom (64-bit)| (default, Sep 19 2017, 08:03:39) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
  File "C:\Users\ishan\AppData\Roaming\Python\Python36\site-packages\pandas\__init__.py", line 26, in <module>
from pandas._libs import (hashtable as _hashtable,
  File "C:\Users\ishan\AppData\Roaming\Python\Python36\site-packages\pandas\_libs\__init__.py", line 3, in <module>
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
ModuleNotFoundError: No module named 'pandas._libs.tslib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ishan\AppData\Roaming\Python\Python36\site-packages\pandas\__init__.py", line 35, in <module>
"the C extensions first.".format(module))
ImportError: C extension: No module named 'pandas._libs.tslib' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.

我尝试了以下解决方案:

  1. 从git克隆pandas并运行SETUP.py(在直接安装到我的win10操作系统中的python 3.6实例上)
  2. 使用anaconda作为python发行版和conda安装熊猫
  3. 更新microsoft visual c++2017可再发行版
  4. 正在更新C:\ProgramData\Anaconda3\Lib\site packages\PyInstaller\hooks\hook-pandas.py

这些似乎都不起作用。请帮助我了解这里的问题是什么。


Tags: theinpyimportpandaspackageslinesite