【问题标题】:No module named 'pandas._libs.tslib'没有名为“pandas._libs.tslib”的模块
【发布时间】:2019-06-03 05:13:30
【问题描述】:

我无法导入熊猫

 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 笔记本电脑上运行!!

【问题讨论】:

  • @Chris 我更新了熊猫,但问题仍然存在!
  • 我们需要更多信息:这是完整的回溯吗,您可以在编辑器中导入 pandas,pyinstaller 是否出现此错误,您是否使用 anaconda,您是否正在运行 mac windows linux 等。

标签: python pandas module pip


【解决方案1】:

我遇到了类似的问题,并通过手动卸载熊猫然后使用 pip 安装熊猫来解决它。你提到你只更新了熊猫。所以我假设你没有尝试重新安装它。

这样做时,我的环境中的 pandas 版本从 0.23.4 更改为 0.24.1

我的环境:

python 3.6.7

点 18.1

注意:我也是 Python 使用的初学者。更有经验的用户可能知道更好的方法。

pip uninstall pandas
pip install pandas 

以上步骤解决了我的问题,我可以导入熊猫了。

我查看了 pandas 社区的发行说明,似乎对 tslib 的依赖已被删除。 检查以下链接中的第 1.5 节并搜索 tslib。

http://pandas.pydata.org/pandas-docs/version/0.24/pandas.pdf

【讨论】:

  • 全新安装的好建议。我没有卸载重装,而是用所有最新的python、pandas、numpy、scipy等创建了一个conda环境,这也解决了问题。
  • 如果我没有 pip 怎么办。并且不想拥有它。我的应用程序从命令行工作,但从 PyCharm 启动时失败并出现此异常
【解决方案2】:

我遇到了同样的错误并通过调用以下命令解决了它:

pip uninstall pandas  
pip install pandas
pip3 install --upgrade pandas

【讨论】:

    猜你喜欢
    • 2018-10-09
    • 2016-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-17
    • 2016-05-06
    • 2018-04-13
    • 2021-02-06
    相关资源
    最近更新 更多