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
gunjansa_ms
Employee
Employee

Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScriptRuntimeException-Transforming data python

Facing error while trying to transform data in powerbi using python script. 

For initial script just tries to print string

print('done')

But this fails statin below error. Have installed Python version 3.7.4 with anaconda environment.

Have PowerBi Version: 2.75.5649.582 64-bit (November, 2019)

Have tried uninstalling and reinstalling pandas and matplotlib but no luck.

 

DataSource.Error: ADO.NET: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib
File "C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\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: DLL load failed: The specified module could not be found.

Details:
DataSourceKind=Python
DataSourcePath=Python
Message=Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib
File "C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\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: DLL load failed: The specified module could not be found.

ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScriptRuntimeException

1 ACCEPTED SOLUTION

I was able to fix this. There is no issue with installation of libraries. 

Bug is there in PowerBI. Even after providing the path of Python in settings, it expects environment variable PATH to be set with below paths.

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Library\mingw-w64\bin

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Scripts

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Library\bin

 

Please get this fixed as this is an unnecessary additional step which took 3 days to debug the issue.

View solution in original post

12 REPLIES 12
v-yuta-msft
Community Support
Community Support

@gunjansa_ms ,

 

From the source code below, you may lost hard dependency modules, please check if you have installed: numpy, pytz, dateutil.

# flake8: noqa

__docformat__ = "restructuredtext"

# Let users know if they're missing any of our hard dependencies
hard_dependencies = ("numpy", "pytz", "dateutil")
missing_dependencies = []

for dependency in hard_dependencies:
    try:
        __import__(dependency)
    except ImportError as e:
        missing_dependencies.append("{0}: {1}".format(dependency, str(e)))

if missing_dependencies:
    raise ImportError(
        "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
    )

 

Community Support Team _ Jimmy Tao

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

I was able to fix this. There is no issue with installation of libraries. 

Bug is there in PowerBI. Even after providing the path of Python in settings, it expects environment variable PATH to be set with below paths.

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Library\mingw-w64\bin

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Scripts

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Library\bin

 

Please get this fixed as this is an unnecessary additional step which took 3 days to debug the issue.

I had already added these in environment variable PATH, I had another extra step was to start Power BI go to --> File --> Options and Settings --> Options --> Python scripting --> Change Detected Python IDEs: "Other" and select "C:\Users\<username>\Anaconda3\Scripts\conda.exe" ****Note: this path depends on where you installed conda.exe --> OK.

 

Restart Power BI and then any script works.

 

Thanks

Thanks a lot, with this final step I fixed the issue.

How to set this environment varaibles can you send me screenshot

Can you guys provide specifically what had to be done here?

 

I spent a whole work day trying to debug/fix this issue. After a whole lot of reading posts on google, stack overflow and countless iteration of updating anaconda, uninstall/reinstall numpy, I stumbled across this post. Thanks @gunjansa_ms for the workaround. Cannot believe it was as easy as adding a few environemntal variables. Hopefully the PowerBI team fixes this soon or update their documentation to set the path variable. 

@gunjansa_ms 

providing that the variable path needto be add ...it  is not enough explanation.

This how: https://www.h3xed.com/windows/how-to-add-to-and-edit-windows-path-variable

 

looks this @HeliosOne  link https://community.powerbi.com/t5/Desktop/error-Working-Directory-does-not-exit/td-p/676990
if you add them in the Path .. It start the python  to work from Anaconda

 

Thank you Sir @gunjansa_ms! I solved it by adding anaconda3\Scripts and anaconda3\Library\bin to PATH variable.

 

@gunjansa_ms 

Could you explain how actually you define PATH variable with paths in your message? I am facing same problem and my skill is not enough to fix this. A little guide would be great.

Thank you!

Go to Properties of your PC.

Go to Change settings

Go to Environment Variables

Go to Path in System Variables. Add Paths.

 

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Library\mingw-w64\bin

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Scripts

C:\Users\gunjansa\AppData\Local\Continuum\anaconda3\Library\bin

 

PythonPathVariables.JPG

@gunjansa_ms  @perezco

 Thank you guys for that explanation. You are real Python ninjas! 🙂

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.