Avoid Python Errors in Power BI

When integrating Python into Power Bi, you will often be faced with integration issues. However, luckily, there is a very easy way to avoid these problems. In this post, we are going to evaluate how to sidestep some of the major errors with Python in Power BI.

Missing Dependencies

The most common error is that there are missing dependencies. The most common one is “numpy” missing dependencies. If you know anything about Python installation, you know that numpy is already installed. So this is not the case, You can view the error in the preformatted box below.

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

This is visual. That appears if you try to use Python-integrated images

You may find the errors in the Power Query editor. However, this is what you will see if you try to use Python script without activating your enviroment.

Why Do You Get This Error?

For the Anaconda installation, the actual environment in which the Power BI Python scripts will run needs to be activated. So all you need to do is start PBI Desktop from within an activated Anaconda environment that matches the one configured in the Python Scripting options in your Power BI options.

Best Way to Avoid Missing Dependency Errors

Firstly, you need to launch Power BI, from your Python environment. Firstly, you need to identify your Python environment. You can easily see this by following the steps below:

  1. Click File
  2. Options and settings
  3. Options
  4. Python Scripting

The image is pointing to your base environment. More than likely if you haven’t created any new environments, you will be using the base environment for Anaconda. At this point, things get quite easy. You only need to activate your environment in Anaconda and then launch Power BI from that environment. Here is how.

Launch Power BI from the Anaconda Activated Environment

  1. Click Anaconda Prompt
  2. Type conda activate
  3. Paste in your Power BI exe path: “C:\Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe”
  4. Power BI will launch and no errors will occur.

Gaelim Holland

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments