首页 > 解决方案 > 在 Power BI 中运行 python 脚本时出错:无法导入所需的依赖项:Numpy

问题描述

我最近将 Anaconda 安装到我的系统 (Win10) 中,并在 conda 中创建了一个虚拟环境来安装几个包和依赖项,以便将其连接到 Power BI,以便我可以运行 Python 脚本。

在那个虚拟环境中,我安装了 Python 3.6 和许多其他依赖项。多次运行脚本后,我也安装了conda install -c intel mkl-service,但是 Numpy 似乎存在问题。我检查了 Numpy 版本 1.19.1,它说需要 Python 3.6 或更高版本,这就是我所拥有的。

有趣的是,在 Jupyter 上一切正常(使用相同的环境内核),但在 Power BI 中却不行

不确定如何继续,也许通过 pip 卸载 Numpy 并通过 conda 重新安装?

任何建议都会有所帮助

这是错误:


Please note and check the following:
  * The Python version is: Python3.6 from "C:\Users\creyes\Anaconda3\envs\myenv\python.exe"
  * The NumPy version is: "1.19.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed: No se puede encontrar el módulo especificado.
Details:
    DataSourceKind=Python
    DataSourcePath=Python
    Message=Python script error.
C:\Users\creyes\Anaconda3\envs\myenv\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured.

Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init

Traceback (most recent call last):
  File "PythonScriptWrapper.PY", line 2, in <module>
    import os, pandas, matplotlib
  File "C:\Users\creyes\Anaconda3\envs\myenv\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. This error can happen for
many reasons, often due to issues with your setup or how NumP...
    ErrorCode=-2147467259
    ExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScriptRuntimeException

标签: pythonnumpypowerbi-desktop

解决方案


推荐阅读