如何解决此熊猫导入错误?

时间:2020-05-31 04:05:37

标签: python pandas intellij-idea

使用pip install安装 pandas 并尝试使用 IntelliJ

导入 pandas 时,出现此错误
C:\Users\Start\venv\Pyhon3.7\Scripts\python.exe D:/PYTHON/HelloWorld/HelloWorld.py
Traceback (most recent call last):
  File "C:\Users\Start\venv\Pyhon3.7\lib\site-packages\pandas\__init__.py", line 30, in <module>
    from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
  File "pandas\_libs\hashtable.pyx", line 1, in init pandas._libs.hashtable
ImportError: DLL load failed: %1 is not a valid Win32 application.

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "D:/PYTHON/HelloWorld/HelloWorld.py", line 25, in <module>
    import pandas as pd
  File "C:\Users\Start\venv\Pyhon3.7\lib\site-packages\pandas\__init__.py", line 38, in <module>
    "the C extensions first.".format(module)
ImportError: C extension: DLL load failed: %1 is not a valid Win32 application. 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 个答案:

答案 0 :(得分:0)

如果您使用的是Pycharm

  1. 转到设置。
  2. 转到项目:(项目名称)
  3. 转到Project Interpreter,然后下载所有模块。也许熊猫未正确安装

请检查您使用的python版本是否也是64位。如果没有,那可能就是问题所在。您将使用32位python版本,并已为pandas库安装了64位二进制文​​件。 您也可以转到Unofficial Windows Binaries for Python Extension Packages查找任何python库。