Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

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:
 

Kindly help :)

17 Replies

  • Anonymous's avatar
    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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      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.


       

      • AMM's avatar
        AMM
        Frequent Visitor

        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.

         

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

    • barakb32's avatar
      barakb32
      Advocate I

      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 

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you! 🙂👍🏾

  • bclrk's avatar
    bclrk
    Advocate II

    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

     

    • Echicken07's avatar
      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/665102

       

      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's avatar
      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,

       

       

      • bclrk's avatar
        bclrk
        Advocate II

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

  • 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!