python - 导入 numpy c 扩展失败

标签 python numpy visual-studio-code miniconda

导入 numpy c 扩展失败

我在 Windows 系统上安装了python 3.7来处理Visual Studio代码。一切都很顺利,包括使用图书馆。 我使用控制面板中的卸载程序工具卸载了 python。并安装了Miniconda 3。 我检查一切正常,然后在 Windows 上的终端 GitBash 中使用 conda install numpy 安装了 numpy 库10,然后在我的visial studio代码上检查了它,但启动失败。

重现代码示例:

import numpy as np
A = np.array([[-1], [7], [-26]])

错误消息:

Traceback (most recent call last): File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy\core__init__.py", line 17, in from . import multiarray File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy\core\multiarray.py", line 14, in from . import overrides File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy\core\overrides.py", line 7, in from numpy.core._multiarray_umath import ( ImportError: DLL load failed: Не найден указанный модуль.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:/Users/ramim/Desktop/22/Matrix library/alsf.py", line 3, in import numpy as np File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy__init__.py", line 142, in from . import core File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy\core__init__.py", line 47, in raise ImportError(msg) ImportError:

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\ramim\Miniconda3\python.exe", and that you have no directories in your PATH or PYTHONPATH that can interfere with the Python and numpy version "1.17.3" 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: Не найден указанный модуль.

Numpy/Python 版本信息:

Python 3.7.5 Numpy 1.17.3

我尝试再次卸载并安装numpy库,但没有用。 注意:当我输入终端 conda install numpy 时,它会显示:

All requested packages already installed

这就是我检查 numpy 是否真的安装的方法!

如何解决这个问题?

最佳答案

首先尝试卸载 numpy 和 setuptools:

  1. pip uninstall -y numpy

  2. pip uninstall -y setuptools

  3. pip install setuptools

  4. pip 安装 numpy

借用了 mehdiHadji 提供的解决方案 - https://github.com/ipython/ipyparallel/issues/349

关于python - 导入 numpy c 扩展失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58868528/

相关文章:

Python:使用request从网页获取自动建议的结果

python - 无法在 Django 中运行 Scrapy 项目

python - 数组中所有值的索引

python-3.x - 用 NaN 填充条件后的值

html - 在恼人的 vue 的 html 格式上禁用 eslint-prettier

python - 在字典中找到最相关的 child

python - Python从文件中读取数据 block

python - 从列表创建多维 numpy 数组

github - VS代码错误:生成git ENOENT

azure - 限制 Visual Studio Code -> 部署到函数应用