Numpy: 导入numpy C-扩展名失败。

创建于 2020-01-27  ·  5评论  ·  资料来源: numpy/numpy

问题

导入熊猫时,出现以下错误:


  File "D:\code\folder1\folder2\metadata\lidar_processing.py", line 17, in <module>
    import pandas as pd

  File "C:\Users\MyUserName\.conda\envs\EnvName\lib\site-packages\pandas\__init__.py", line 17, in <module>
    "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)

ImportError: Unable to import required dependencies:
numpy: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
  1. Check that you expected to use Python3.7 from "C:\Users\MyUserName\.conda\envs\EnvName\pythonw.exe",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.17.5" you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.

Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.

Original error was: DLL load failed: The specified module could not be found.

安装numpy

通过win10上的anaconda完成安装:

conda create --name EnvName python=3.7 python-pdal geopandas --channel conda-forge  
conda activate MyEnv
conda install spyder-kernels

conda list命令显示numpy:
numpy 1.17.5 py37hc71023c_0 conda-forge

其他资讯

  • Windows 10版本1803(操作系统内部版本17134.706)
  • 通过conda install --force-reinstall numpy=1.17.5重新安装numpy无法解决问题。
  • 请注意, conda install numpy将提供对1.18.1的更新,但这会导致其他关于Geopandas的导入错误(但是,这些错误并未直接提及numpy)。
32 - Installation 33 - Question

所有5条评论

从Windows 10上的64位ananconda3_2019_10 64位全新安装开始,您粘贴的命令对我来说很好用。 我也得到相同的numpy,但是我可以毫无问题地导入numpy和pandas。

> conda list | find "numpy"
numpy                     1.17.5           py37hc71023c_0    conda-forge

请注意,conda / anaconda使用MKL,外部参照gh-15343,gh-14888等

我做了一些进一步的测试。 我删除了计算机上的所有现有环境。 不幸的是,我确实不记得我是否做了conda update conda
然后,我通过以下方式创建了一个新环境:
conda create --name pdal3 --channel conda-forge python=3.7 spyder-kernels python-pdal geopandas
请注意,此命令与原始帖子中的命令不同(参数顺序和立即集成的spyder-kernels)。
我得到以下结果:

  1. spyder控制台中的错误:请参见spyder github 。 但是,这似乎是一个棘手的问题。
  2. 当我直接从控制台启动程序时,它可以工作。

因此,我可以暂时继续我的工作,但不能对我如何解决该问题提供任何见解。

这是Spyder中的一个问题,原因是我们在启动内核之前未激活conda env。 它已在我们的4.1.0版本中修复,因此可以解决此问题。

@ ccordoba12感谢您的更新。

我可以确认问题不再存在。 感谢numpy和spyder社区花费的时间。

此页面是否有帮助?
0 / 5 - 0 等级