Monirrad
Monirrad

Reputation: 483

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. I have changed the option and activated the 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.

I have installed numpy and pandas again and I got the message below

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. I tried a lot of ways and nothing could help

Upvotes: 4

Views: 14231

Answers (6)

I had a somewhat related problem with Power BI not finding a dependency (matplotlib in my case). In my case, I had multiple versions of Python installed and it was referring to the old one; I just needed to change the configuration to use the most recent version.

Upvotes: 0

Dr. Sushant_Bahekar
Dr. Sushant_Bahekar

Reputation: 161

  1. Open Anaconda Navigator

  2. Create new environment e.g. PowerBIEnvironment

  3. Open Anaconda Prompt

  4. Type command to Activate PowerBIEnvironment - activate PowerBIEnvironment

  5. Install respective libraries e.g. Pip install numpy

  6. Open PowerBI Desktop

  7. Goto File --> Options and Setting --> Options --> Python Scripting -->

  8. Select Other in Detected python home directories

  9. Give newly created environment path in Set a python home directory e.g. C:\Users\XYZPQR\Anaconda3\envs\PowerAutomateEnvironment

  10. Refresh Power BI

Upvotes: 0

Odarnoc
Odarnoc

Reputation: 29

forget Anaconda and use WinPython. I tried Anaconda for days with all the workarounds available in StackOverflow and other forums, and they took me nowhere. Then I tried WinPython, and it worked immediately. Of course, you will need to change the PowerBI options accordingly.

  1. To install WinPython: https://github.com/winpython/winpython
  2. To change the detected Python home directory: https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts#enable-python-scripting

If you consider my answer above others, you won't need to downgrade Python, PBI, or anything else.

Upvotes: 2

Ashish Jain
Ashish Jain

Reputation: 467

Open the Anaconda Prompt: Then, you have to go to the Conda Environment that you want to use in PowerBI. Am having an environment 'temp', so I activate it first in the 'Anaconda Prompt':

(base) C:\Users\ashish>conda activate temp

Then I go to the directory having the "PowerBI" executable file in the installation folder:

(temp) C:\Users\ashish>cd "C:\Program Files\Microsoft Power BI Desktop\bin"

Then, I launch PowerBI from the Prompt:

(temp) C:\Program Files\Microsoft Power BI Desktop\bin>PBIDesktop.exe

This fixes the NumPy error you are getting. If you want any other package to use with PowerBI, install that package in the respective "Conda Environment" (in my case it is "temp").

Upvotes: 5

oweste
oweste

Reputation: 11

I had similar issue trying to get Power BI to use Anaconda Python. After seeing a post about PBI having issues with Python 3.7 I:

  1. Created a new environment in Anaconda using the Anaconda Navigator and made sure the new environment were using Python 3.6 (so NOT 3.7).
  2. Installed in that environment the packages such as Pandas, Matplotlib and Seaborn that were used in my Power BI Python script
  3. Went to Power BI's settings: File/Options and Settings/Options/Python scripting and set "Other" for Detected Python home dir and instead navigated to my new 3.6 python environment directory (visable in Anaconda Navigator at the bottom of the screen when selecting that environment)

..and that worked fine.

Upvotes: 1

guiyom-e
guiyom-e

Reputation: 19

I think this error can be due to some numpy issues with Anaconda distribution. 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.

Upvotes: 0

Related Questions