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 🙂

10 REPLIES 10
Highlighted
ToC Frequent Visitor
Frequent Visitor

Re: Python Integration Error

@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.

pkoetzing Regular Visitor
Regular Visitor

Re: Python Integration Error

I'm had exactly the same issue and error msg as @Anonymous .  So I checked out @ToC '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!

stevenguyen2290 New Member
New Member

Re: Python Integration Error

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


@ToC 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.


 

AMM Frequent Visitor
Frequent Visitor

Re: Python Integration Error

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. 

bclrk Frequent Visitor
Frequent Visitor

Re: Python Integration Error

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

 

AMM Frequent Visitor
Frequent Visitor

Re: Python Integration Error

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,

 

 

bclrk Frequent Visitor
Frequent Visitor

Re: Python Integration Error

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
Frequent Visitor

Re: Python Integration Error

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

barakb32 Regular Visitor
Regular Visitor

Re: Python Integration Error

Hi @ToC ,

 

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 

 

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,003)