Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jono
Frequent Visitor

importing dataframe with python throws script error

When I try to import a dataframe to Power BI using a Python script I get the following error

 

Details: "ADO.NET: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib.pyplot
File "C:\Users\jonow\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
"

 

This happens even when I enter no Python code, and the code runs fine in an IDE.

I am using Python with anaconda so the file Path I have specified in Power BI is C:\Users\Username\Anaconda3

Is this correct ? ? ? 

Tried everything and cant get this working.

1 ACCEPTED SOLUTION

Hi @Anonymous @jono,

 

@Anonymous Thank you for your information. Power doesn't have the feature which can run a cmd batch file when open. As a workaround, you can install the batch as a windows service. Please refer to: https://stackoverflow.com/questions/415409/run-batch-file-as-a-windows-service.


Regards,

Jimmy Tao

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hello,

I have the same problem.  I kind of understand why.  I am also using Anaconda and I get the same error when I try to run a query:

 

File "PythonScriptWrapper.PY", line 2, in <module>
    import os, pandas, matplotlib.pyplot
  File "C:\Users\bharat.c.ruparel\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
    "Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
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.pyplot
  File "C:\Users\bharat.c.ruparel\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
    "Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
    ErrorCode=-2147467259
    ExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScr
 
The reason that this is happening is numpy is a dependency for pandas package and your environment must be able to find this package when it calls "import pandas".  Anaconda manages this process by "activating" the conda environment BEFORE importing anything by running the activate.bat file.  In my case it is located at:
 
C:\Users\bharat.c.ruparel\AppData\Local\Continuum\anaconda3\Scripts\activate.bat
 
This needs to be run to set up the conda environment.  I do not know how to run this batch file from within Power BI so that it can find the necessary dependencies.
 
does anyone know?

Hi @Anonymous @jono,

 

@Anonymous Thank you for your information. Power doesn't have the feature which can run a cmd batch file when open. As a workaround, you can install the batch as a windows service. Please refer to: https://stackoverflow.com/questions/415409/run-batch-file-as-a-windows-service.


Regards,

Jimmy Tao

Anonymous
Not applicable

So I could not solve it using the service approach.  Besides, it is kind of hackish.  I ended up doing another straight Python install using the conventional windows installer and then pip installing the pandas package.  I put this intalled version of Python in the PATH environment variable.

 

So I have two installations of the same versions of Python 3.7.  One with Anaconda, and another by itself.  Since the standalone Python does not require activation of the Conda environment, it worked fine.

 

I know it is sub-optimal, but it works.  Power BI developers need to support different Pyenv and Conda environments in the future releases of Python support.

 

Bharat

Anonymous
Not applicable

Thank you @Anonymous , this worked! I only had Anaconda as well (as I'm sure many will or Anaconda/Pycharm), so this was the only suggestion that worked for me. I can't wait to have fun with Python + PowerBI !

1) As mentioned, I had to pip install Pandas (which then automatically installs numpy because of dependencies).

2) Additionally, I had to also pip install matplotlib (even though my script did not import matplotlib).

v-yuta-msft
Community Support
Community Support

Hi jono,

 

This may caused by numpy module hasn't be installed when you installed anaconda. You can open CMD and type "conda list" to check all the modules included by anaconda, if numpy is not listed, type "conda install numpy" to install numpy module.

 

Regards,

Jimmy Tao

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.