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.
我尝试了以下解决方案:
- 从Git克隆pandas并运行SETUP.py(在直接安装到我的Win10操作系统的Python 3.6实例上)
- 使用Anaconda作为Python分发和conda安装pandas
- 更新Microsoft Visual C++ 2017可再发行包
- 更新C:\ ProgramData \ Anaconda3 \ Lib \ site-packages \ PyInstaller \ hooks \ hook-pandas.py
AppData\Roaming
是什么?提示中显示“Anaconda custom”,你是如何安装Anaconda的? - Andy Haydensetup.py build_ext
,除非你正在从源代码构建,而你不应该这样做。我猜测虚拟环境没有使用anaconda,并且pandas的安装出了问题(可能是在安装anaconda之前创建的?)。我建议删除此目录C:\Users\ishan\AppData\Roaming\Python\Python36
,看看是否有所帮助。 - Andy Hayden