我无法导入 Pandas
C:\Users\Yash\Desktop\Python\Twitter Sentimental Analysis>python import.py
Traceback (most recent call last):
File "C:\Users\Yash\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\__init__.py", line 26, in <module>
from pandas._libs import (hashtable as _hashtable,
File "C:\Users\Yash\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\_libs\__init__.py", line 4, 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 "import.py", line 4, in <module>
import pandas as pd
File "C:\Users\Yash\AppData\Local\Programs\Python\Python36\lib\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.
我试着搞砸了,但这个错误仍然存在。 我已经更新了模块以及 pip 和 python!
这是命令的完整回溯。
我目前使用的是python 3.6.6(官网下载)
pip 版本:18.1 在 Windows 10 笔记本电脑上运行!!
最佳答案
我遇到了类似的问题并通过手动卸载 pandas 然后使用 pip 安装 pandas 解决了这个问题。你提到你只更新了 Pandas 。所以我假设您还没有尝试重新安装它。
这样做时,我环境中的 pandas 版本从 0.23.4 更改为 0.24.1
我的环境:
python 3.6.7
18.1 pip
注意:我也是 Python 使用的初学者。更有经验的用户可能知道更好的方法。
pip uninstall pandas
pip install pandas
上述步骤解决了我的问题,我可以导入 pandas。
我查看了 pandas 社区的发行说明,似乎已经删除了对 tslib 的依赖。 检查以下链接中的第 1.5 节并搜索 tslib。
http://pandas.pydata.org/pandas-docs/version/0.24/pandas.pdf
关于python - 没有名为 'pandas._libs.tslib' 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54093020/