cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Python Integration Error

Hi All,

 

I am getting the following error while using python visual. I made use of anaconda distribution for python installation.

 

Following is the error :

 

Error Message:
Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, matplotlib.pyplot, uuid, pandas
File "C:\Users\jasKsing\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\__init__.py", line 141, in <module>
from . import cbook, rcsetup
File "C:\Users\jasKsing\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 33, in <module>
import numpy as np
File "C:\Users\jasKsing\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\jasKsing\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

 

Following is the script :

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:

# dataset = pandas.DataFrame(FullDate, UnitPrice, Quantity)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:
import pip
import matplotlib.pyplot as plt
dataset.plot()
 
Following is the setting are options in power bi:
python settings pbi.PNG 

Kindly help 🙂

15 REPLIES 15
bclrk
Advocate I
Advocate I

I was able to fix this issue by using pip to uninstall matplotlib and pillow and then reinstall them. That is:

pip uninstall matplotlib
pip uninstall pillow
pip uninstall numpy pip install matplotlib pip install pillow
pip install numpy

 

Thank you!

mficco
Frequent Visitor

This worked for me! Thanks!

Echicken07
Frequent Visitor

I've been at this for 3 days and couldn't figure it out.

 

Kept getting the same error messages as the following cases:

1. https://community.powerbi.com/t5/Desktop/Microsoft-PowerBI-Scripting-Python-Exceptions/td-p/850714

2. https://community.powerbi.com/t5/Desktop/Power-BI-Python-with-Anaconda-missing-dependency/td-p/66510...

 

It wasn't until I ran the following uninstall and reinstall scripts in CMD that it FINALLY worked!! You are a life saver. Thank you so much.

AMM
Frequent Visitor

I of course tried this then tried to create a python visualization or at least print("Hello") and I got the following error:

 

ImportError: DLL load failed: The specified module could not be found.

The default imports seem to be: os, uuid, matplotlib

Then later numpy as np

 

I'll submit another frown, but to say it didn't just work would be an understatement. I did test that I could use matplotlib, numpy, pandas etc. in Jupyter notebook even seaborn.

 

I ran your suggested installs and uninstalls in the order you suggested from the command line built into JupyterLab FWIW.

 

Cheers,

 

 

You may have already tried this but a pip uninstall and install of numpy and any other packages in the error could help.

AMM
Frequent Visitor

Of course I tried reinstalling months ago, but I did it again. Seaborn still does not work maybe I should use pip on that but I persisted with some test code as I got a different error after reinstalling numpy. I didn't use any PowerBI integration but I was able to use this code:

from matplotlib import pyplot as plt
import numpy as np
def sinplot(flip = 1):
   x = np.linspace(0, 14, 100)
   for i in range(1, 5):
      plt.plot(x, np.sin(x + i * .5) * (7 - i) * flip)

sinplot()
plt.show()

To get below so thanks, but 

actualMatplotLibInPowerBI.png

pkoetzing
Advocate III
Advocate III

I'm had exactly the same issue and error msg as @Anonymous .  So I checked out @Anonymous 's recipe, but unfortunately it didn't work for me.  I figured out that installing anaconda (conda install anaconda) just linked to the existing packages and didn't leave anything for the pip installer to do. But w/o installing anaconda (conda install -n py37 python=3.7) plus the subsequent pip installs all the packages (incl. vs2015_runtime) got newly downloaded and afterwards my Python visual worked like a charm. Thanks for your help, guys!

Anonymous
Not applicable

@Anonymous ,

 

Do you know what version of Python your Anaconda environment is using? I was running into issues importing packages with 3.6 and 3.7.

 

I was able to get around the error by creating a new conda env with Python 3.5:

conda create -n py35 anaconda python=3.5

Then pip installing relevant packages (I had issues with PowerBI recognizing conda installs):

 

conda activate py35
pip install matplotlib
pip install pandas

 

After this is complete, you need to point PowerBI to the new env.

 

Including steps for those less familiar:

File -> Options and Settings -> Options -> Python Scripting

 

Then add the Path to your new Env. Mine looks like:

"C:\ProgramData\Anaconda3\envs\py35"

 

This thread tipped me off to the issue:

https://developercommunity.visualstudio.com/content/problem/362404/importerrordll-load-failed-the-specified-module-co.html

 

Let me know if you have questions.

Excellent! Thank you very much

Thank you! 🙂👍🏾

Hi @Anonymous ,

 

Your solution did the job for me.

However I had to have an extra step: copying the environemnt folder from the C:\Program Files to another location, since the Python Script options in Power BI Desktop doesn't allow browsing to the C:\Program Files (probably IT policy).

 

Do you know how to configure the path in which the new env will be created within conda create?

 

Thanks,

Barak 

 

great solution, I fixed the ImportError based on your suggested solution. Thank you very much


@Anonymous wrote:

@Anonymous ,

 

Do you know what version of Python your Anaconda environment is using? I was running into issues importing packages with 3.6 and 3.7.

 

I was able to get around the error by creating a new conda env with Python 3.5:

conda create -n py35 anaconda python=3.5

Then pip installing relevant packages (I had issues with PowerBI recognizing conda installs):

 

conda activate py35
pip install matplotlib
pip install pandas

 

After this is complete, you need to point PowerBI to the new env.

 

Including steps for those less familiar:

File -> Options and Settings -> Options -> Python Scripting

 

Then add the Path to your new Env. Mine looks like:

"C:\ProgramData\Anaconda3\envs\py35"

 

This thread tipped me off to the issue:

https://developercommunity.visualstudio.com/content/problem/362404/importerrordll-load-failed-the-specified-module-co.html

 

Let me know if you have questions.


 

I too am encountering this error. 

 

I chose to intall Anaconda and this resulted in Python version 3.7.3 being installed. I have verified using the command line and Jupyter notebooks that python, numpy, pandas, matplotlib and even seaborn work. I tried upgrading python using conda. I also tried creating a new enviroment version 3.7.1 which is supposedly the supported Python version. That too did not work, I could not navigate to the environment veriable from inside Power BI but I could change to that environment using the command line.

 

I tried replying earlier but now that I have created an account I can post a screen shot showing my inability to navigate to the Anaconda environment.

noEnv.png

 

I may need to get someone with administrator privlidges or completly blow away Anaconda but I was able to install Anaconda without administrator privlidges. 

@AMM 

 

I ran into the same but manged to find a solution:

1. In your Windows Explorer search for afolder named Continuum. Within this folder you will find /anaconda3/envs. If that doesn't work try:

    a. Copy the current path of Pyrthon Home Directory and paste in your Windows Explorer

    b. Browse up to the anaconda3 folder 

    c. Browse down to /envs folder

2. Copy the py35 folder (subfolder in /Continuum/anaconda3/envs) to a location that you can browse to from Power BI Desktop

 

Barak

 

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Solution Authors