Forum Discussion

shmat's avatar
shmat
Regular Visitor
7 years ago

Error with SEABORN

Hi,

 

I am getting error when trying to import seaborn and work with it.

 

import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
# create data
x = np.random.rand(80) - 0.5
y = x+np.random.rand(80)
z = x+np.random.rand(80)
df = pd.DataFrame({'x':x, 'y':y, 'z':z})
# Plot with palette
sns.lmplot( x='x', y='y', data=df, fit_reg=False, hue='x', legend=False, palette="Blues")
plt.show()
 
Interestingly, when using matplotlib veerything works fine.
 
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
# create data
x = np.random.rand(80) - 0.5
y = x+np.random.rand(80)
z = x+np.random.rand(80)
df = pd.DataFrame({'x':x, 'y':y, 'z':z})
# Plot with palette
plt.plot(x,y,'b.')
plt.show()
 
The error I get when attempting to import seaborn is:
 
Error Message:
Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 16, in <module>
import seaborn as sns
File "C:\Users\paeres\AppData\Local\Continuum\anaconda3\lib\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Users\paeres\AppData\Local\Continuum\anaconda3\lib\site-packages\seaborn\rcmod.py", line 5, in <module>
from . import palettes, _orig_rc_params
File "C:\Users\paeres\AppData\Local\Continuum\anaconda3\lib\site-packages\seaborn\palettes.py", line 12, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Users\paeres\AppData\Local\Continuum\anaconda3\lib\site-packages\seaborn\utils.py", line 7, in <module>
from scipy import stats
File "C:\Users\paeres\AppData\Local\Continuum\anaconda3\lib\site-packages\scipy\stats\__init__.py", line 345, in <module>
from .stats import *
File "C:\Users\paeres\AppData\Local\Continuum\anaconda3\lib\site-packages\scipy\stats\stats.py", line 169, in <module>
import scipy.special as special
File "C:\Users\paeres\AppData\Local\Continuum\anaconda3\lib\site-packages\scipy\special\__init__.py", line 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.

10 Replies

  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi shmat ,

    By my tests and research, your issue may be caused by that you didn't install the package seaborn.

    You need install the package seaborn with command like below.

    Then use your script in Power BI Desktop, you could get the output.

    Best  Regards,

    Cherry

     

    • shmat's avatar
      shmat
      Regular Visitor

      Hi Cherry,

       

      Thank you for your swift reply. Seaborn package has been installed before and, to be on the safe side, I did it again now.

       

      This, however, did not solve my problem. I am still getting the same error.

      Could there be anything else I am doing wrong? Maybe some other updates are needed?

       

      In fact, the error is coming from "import seaborn as sns". If I run simply "import matplotlib.pyplot as plt" it says:

       

      I do not get why seaborn does not work...

      • v-piga-msft's avatar
        v-piga-msft
        Resident Rockstar

        Hi shmat ,

        Please check if you have installed the latest version of Power BI Desktop (2.69.5467.1751).

        In addition, please have a test with the pbix attached which run Seaborn well in your environment.

        Best  Regards,

        Cherry

         

  • RomanSk's avatar
    RomanSk
    Frequent Visitor

    shmat - Have you solved the problem? I have the same issue.

    • shmat's avatar
      shmat
      Regular Visitor

      RomanSk wrote:

      shmat - Have you solved the problem? I have the same issue.


      Hi RomanSk,

       

      Unfortunately, I did not manage to make it work. Still cannot find the reason.

      Please let me know if you manage.

      I have tried re-installing Power BI and re-installing the library.

      • RomanSk's avatar
        RomanSk
        Frequent Visitor

        I solved it this way. I changed home directory from C:\python to C:\Program Files\Python37 in options - Python scripting and it works.

  • Hi, how were you able to use pythin in Power BI desktop?

     

    In Tableau I can use custom quesry as SQL, is it possible in Power BI?