【问题标题】:ImportError: DLL load failed while importing aggregations: The specified module could not be foundImportError:导入聚合时DLL加载失败:找不到指定的模块
【发布时间】:2020-07-01 04:03:15
【问题描述】:

我是 Python 新手,目前在导入某些库时遇到问题。

我正在使用 Python 3.8。

我已经使用“pip install pandas”在 CMD 中安装了 Pandas

如果我转到 Python 文件夹,我会看到 Pandas 已安装:

C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\Lib\site-packages

但是当我尝试在我的脚本中导入 Pandas 时收到此错误消息:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import pandas as pd
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\__init__.py", line 55, in <module>
    from pandas.core.api import (
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\api.py", line 29, in <module>
    from pandas.core.groupby import Grouper, NamedAgg
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\groupby\__init__.py", line 1, in <module>
    from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\groupby\generic.py", line 60, in <module>
    from pandas.core.frame import DataFrame
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\frame.py", line 124, in <module>
    from pandas.core.series import Series
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\series.py", line 4572, in <module>
    Series._add_series_or_dataframe_operations()
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\generic.py", line 10349, in _add_series_or_dataframe_operations
    from pandas.core.window import EWM, Expanding, Rolling, Window
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\window\__init__.py", line 1, in <module>
    from pandas.core.window.ewm import EWM  # noqa:F401
  File "C:\Users\VALENTINA\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\window\ewm.py", line 5, in <module>
    import pandas._libs.window.aggregations as window_aggregations
ImportError: DLL load failed while importing aggregations: The specified module could not be found.

在 Visual Code 和 IDLE 中运行我的脚本时出现此错误消息。

如果有人可以帮助我,我很感激

谢谢

【问题讨论】:

  • 您没有使用虚拟环境或类似工具?你能分享一些关于你的环境的信息吗?
  • 我使用 Pyhton 3.8 和 Visual Studio Code 作为文本编辑器
  • 您是在 VS Code 中还是在命令行中运行代码?如果你安装了 python2,有时 VS Code 会默认安装另一个 python
  • @Valentina 请将问题标记为已解决。另外,最好使用 anaconda 安装 Python,因为它附带了大多数情况下需要的常用包。

标签: python pandas visual-studio-code


【解决方案1】:

我也遇到了同样的问题。我正在使用python 3.7.5。默认情况下pip install pandas 命令安装版本 1.0.3。所以我恢复到 1.0.1 版本。

pip uninstall pandas
pip install pandas==1.0.1

现在它可以正常工作了。你可以试试看。

【讨论】:

  • 感谢我还安装了以前的版本并且能够解决问题
  • 我在以下情况下遇到了同样的问题,这个解决方案对我来说非常有效:使用 Python 3.8.2 创建的 exe,Windows 7 上的 Pyinstaller 3.6。程序应该在 Windows 10 上运行。使用 pandas 1.0。 3、exe在windows 7上运行,但在windows 10上不行。谢谢!
  • 与 pandas 1.0.4 相同的问题
  • Windows 10 的 Python 3.8.3 64 位上的 Pandas 1.0.5 存在同样的问题。安装 1.0.1 效果很好。现在的问题是为什么?
【解决方案2】:

您也可以尝试安装更新版本的 Microsoft Visual C++ Redistributable。

例如(2015-2019)

我遇到了同样的问题,安装上述解决了它。

https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

【讨论】:

  • 您在发布此解决方案时是否使用了 pandas 1.0.3?
  • 我有熊猫 1.0.3
【解决方案3】:

我在导入 pandas 时收到两条错误消息,一条在 OP 中,另一条在

AttributeError: module 'pandas' has no attribute 'plotting'

我能够通过重新安装包/库来缓解问题

pip uninstall pandas
pip install pandas==1.0.1

正如另一位用户在我之前指出的那样。我现在将 Python 3.8.2 与 pandas 1.0.1 结合使用而不会出现问题。

【讨论】:

  • 你节省了我的时间
【解决方案4】:

只需卸载 pandas 并将 pandas 重新安装到 1.0.1

例如:
pip 卸载熊猫
pip install pandas==1.0.1

【讨论】:

    【解决方案5】:

    我遇到了同样的错误(Python 3.9)。这解决了它:

    pip uninstall pandas
    upgrade pip=21.3.1
    pip install pandas
    

    【讨论】:

    • 我猜应该是“升级”,而不是“升级”?
    猜你喜欢
    • 2020-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-22
    • 2021-03-04
    • 2021-09-16
    • 2020-07-11
    • 1970-01-01
    相关资源
    最近更新 更多