[英]Using Python Script in Power BI, ImportError: Missing required dependencies ['numpy']
I am pretty new in Power BI
and I try to set up the python script in it.我是
Power BI
新手,我尝试在其中设置 python 脚本。 I have changed the option and activated the Python scripting
.我已经更改了选项并激活了
Python scripting
。 After that I get the error:之后我收到错误:
DataSource.Error: ADO.NET: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib.pyplot
File "C:\Users\mm\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
Details:
DataSourceKind=Python
I check the conda
list and it contains numpy
.我检查了
conda
列表,它包含numpy
。
I have installed numpy
and pandas
again and I got the message below我再次安装了
numpy
和pandas
,我收到了下面的消息
C:\Users\mm\AppData\Local\Continuum\anaconda3>py -m pip install numpy
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Requirement already satisfied: numpy in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (1.15.4)
C:\Users\mm\AppData\Local\Continuum\anaconda3>py -m pip install pandas
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Requirement already satisfied: pandas in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (0.23.4)
Requirement already satisfied: python-dateutil>=2.5.0 in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (from pandas) (2.7.5)
Requirement already satisfied: pytz>=2011k in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (from pandas) (2018.7)
Requirement already satisfied: numpy>=1.9.0 in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (from pandas) (1.15.4)
Requirement already satisfied: six>=1.5 in c:\users\mm\appdata\local\continuum\anaconda3\lib\site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)
As you see I am using anaconda3 but there is another Python is installed on my macheine.如您所见,我使用的是 anaconda3,但我的机器上安装了另一个 Python。 I tried a lot of ways and nothing could help
我尝试了很多方法,但没有任何帮助
Open the Anaconda Prompt: Then, you have to go to the Conda Environment that you want to use in PowerBI.打开 Anaconda 提示:然后,您必须转到要在 PowerBI 中使用的 Conda 环境。 Am having an environment 'temp', so I activate it first in the 'Anaconda Prompt':
我有一个环境“temp”,所以我首先在“Anaconda Prompt”中激活它:
(base) C:\Users\ashish>conda activate temp
Then I go to the directory having the "PowerBI" executable file in the installation folder:然后我转到安装文件夹中包含“PowerBI”可执行文件的目录:
(temp) C:\Users\ashish>cd "C:\Program Files\Microsoft Power BI Desktop\bin"
Then, I launch PowerBI from the Prompt:然后,我从提示启动 PowerBI:
(temp) C:\Program Files\Microsoft Power BI Desktop\bin>PBIDesktop.exe
This fixes the NumPy error you are getting.这修复了您遇到的 NumPy 错误。 If you want any other package to use with PowerBI, install that package in the respective "Conda Environment" (in my case it is "temp").
如果您希望任何其他包与 PowerBI 一起使用,请在相应的“Conda 环境”(在我的情况下是“temp”)中安装该包。
I had similar issue trying to get Power BI to use Anaconda Python.我在尝试让 Power BI 使用 Anaconda Python 时遇到了类似的问题。 After seeing a post about PBI having issues with Python 3.7 I:
在看到一篇关于 PBI 与 Python 3.7 有问题的帖子后,我:
..and that worked fine. ..而且效果很好。
I think this error can be due to some numpy issues with Anaconda distribution.我认为此错误可能是由于 Anaconda 发行版存在一些问题。 I changed the Python path in Power BI to a virtual environment (which uses pip instead of conda to install numpy and other packages) and I had no more issues.
我将 Power BI 中的 Python 路径更改为虚拟环境(使用 pip 而不是 conda 来安装 numpy 和其他包),并且没有更多问题。
forget Anaconda and use WinPython.忘记 Anaconda 并使用 WinPython。 I tried Anaconda for days with all the workarounds available in StackOverflow and other forums, and they took me nowhere.
我使用 StackOverflow 和其他论坛中提供的所有解决方法尝试了 Anaconda 几天,但它们无济于事。 Then I tried WinPython, and it worked immediately.
然后我尝试了 WinPython,它立即生效。 Of course, you will need to change the PowerBI options accordingly.
当然,您需要相应地更改 PowerBI 选项。
If you consider my answer above others, you won't need to downgrade Python, PBI, or anything else.如果您认为我的回答高于其他答案,您将不需要降级 Python、PBI 或其他任何东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.