Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
thuantv
Helper I
Helper I

Can not run Python script in powerbi desktop

I have create csv file named "dataset" and write a python script to import it to Powerbi desktop. When I get data in powerbi desktop and paste above script, PBI show the error as following: "Details: "ADO.NET: Python script error. C:\Users\Admin\anaconda3\lib\site-packages\numpy_init.py:140: 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 import os, pandas, matplotlib File "C:\Users\Admin\anaconda3\lib\site-packages\pandas_init.py", line 17, in "Unable to import required dependencies:\n" + "\n".join(missing_dependencies) ImportError: Unable to import required dependencies" My python script is: "import pandas as pd import numpy as np import matplotlib from matplotlib import pyplot as plt df = pd.read_csv(r'C:\Users\Admin\Desktop\Python\Python_to_powerbi\Dataset.csv') print(df)" And I also attach my csv file. target=_blank> For more information I use Anaconda with python version is 3.7.4 and Numpy version is...
1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @thuantv ,

 

According to the error message, you may install a package named "mkl-service", and then see if there will be other errors.

 

There are also several points you may considerate for the Python data source:

 

1.Try to install Python on your local machine,  download the latest version of Python from the Python website .

 

2.Install required Python packages,

 

pip install pandas

pip install matplotlib

 

3.Go to File > Options and settings > Options > Python scripting, enable Python scripting .

 

4.When setting the working directory within the Python script, you must define a full path to the working directory, rather than a relative path

 

5.When publish to Power BI Service, to refresh the Python data source, you may need to install the on premise data gateway (personal mode) .

 

For reference:

 

Run Python scripts in Power BI Desktop

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
RClayton_100
New Member

You probably already have all of the necessary modules properly installed, especially if you can use them outside of Power BI.

 

SO......., Under options and settings, in Python Scripting, check your Python home directory.

 

I had to change mine from C:\Users\<......my user name....>\AppData\Local\Programs\Python\Python39

                                   to C:\Users\<......my user name....>\AppData\Local\Programs\Python\Python38-32

v-xicai
Community Support
Community Support

Hi @thuantv ,

 

According to the error message, you may install a package named "mkl-service", and then see if there will be other errors.

 

There are also several points you may considerate for the Python data source:

 

1.Try to install Python on your local machine,  download the latest version of Python from the Python website .

 

2.Install required Python packages,

 

pip install pandas

pip install matplotlib

 

3.Go to File > Options and settings > Options > Python scripting, enable Python scripting .

 

4.When setting the working directory within the Python script, you must define a full path to the working directory, rather than a relative path

 

5.When publish to Power BI Service, to refresh the Python data source, you may need to install the on premise data gateway (personal mode) .

 

For reference:

 

Run Python scripts in Power BI Desktop

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@thuantv - Seems like you are missing a package installation, specifically, "mkl-service"


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.