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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rainynights
Helper II
Helper II

Unable to run Python scripts in Power BI unless PBI was opened from Anaconda Prompt

Hi everyone,

 

So for the longest time, I was experiencing this issue with PBI where my Python scripts just wouldn't run, despite the PATH in "Python Script Options" being correct. 

 

The errors I'd get would be something along the lines of:

 

ADO.NET: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 4, in <module>
import matplotlib.pyplot
File "C:\USERS\SARMIENTOF\APPDATA\ROAMING\CONTINUUM\ANACONDA3\lib\site-packages\matplotlib\pyplot.py", line 32, in <module>
import matplotlib.colorbar
File "C:\USERS\SARMIENTOF\APPDATA\ROAMING\CONTINUUM\ANACONDA3\lib\site-packages\matplotlib\colorbar.py", line 32, in <module>
import matplotlib.contour as contour
File "C:\USERS\SARMIENTOF\APPDATA\ROAMING\CONTINUUM\ANACONDA3\lib\site-packages\matplotlib\contour.py", line 18, in <module>
import matplotlib.font_manager as font_manager
File "C:\USERS\SARMIENTOF\APPDATA\ROAMING\CONTINUUM\ANACONDA3\lib\site-packages\matplotlib\font_manager.py", line 48, in <module>
from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir
ImportError: DLL load failed: The specified module could not be found.

 

The above error seems pretty explanatory - except I had all of the modules needed.

 

At the advice of @pkoetzing here (https://community.powerbi.com/t5/Desktop/Error-when-connecting-python-to-PBI/m-p/854965/highlight/tr...), I tried opening PBI from the Anaconda Prompt, and somehow it works! I'm baffled as to why this is, but opening PBI on its own doesn't let my Python scripts run. The settings in both cases are always the same.

 

Any advice would be appreciated! Ideally I want to set up a gateway here where the data that goes through Python scripts actually work without the PBI having been launched specifically from Anaconda Prompt. Thanks for any help!

1 REPLY 1
v-xicai
Community Support
Community Support

Hi @rainynights ,

 

From the article, we know when preparing and running a Python script in Power BI Desktop, there are a few limitations:

  • Only pandas data frames are imported, so make sure the data you want to import to Power BI is represented in a data frame
  • Any Python script that runs longer than 30 minutes times out
  • Interactive calls in the Python script, such as waiting for user input, halts the script’s execution
  • When setting the working directory within the Python script, you must define a full path to the working directory, rather than a relative path
  • Nested tables are currently not supported

 

You may upgrade the Power BI Desktop to the latest version 2.75.5649.861 , and try it again.

 

If you still have this issue for Power BI, you'd better create a support ticket in Power BI Support , Scroll down and click "CREATE SUPPORT TICKET", to get further help.

 

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.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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