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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Richard917
Regular Visitor

Desktop error when importing python package

I have been researching and hammering on this issue for 2 days.  Hope someone can help.

I am able to successfully run a python script in my Power BI Desktop file, but as soon as I add the import statement for the "Levenshtein" package to the script, I get the following error in the query editor:

DataSource.Error: ADO.NET: Python script error. <pi>ValueError: bad marshal data (unknown type code) </pi> Details: DataSourceKind=Python DataSourcePath=Python Message=Python script error. <pi>ValueError: bad marshal data (unknown type code) </pi> ErrorCode=-2147467259 

Here are some things truobleshooting steps I tried:

1. Added environment variable paths to my computer as mentioned in this post ( I intentionally inserted a space after "https:" and after "community." because my this post keeps getting labeled as spam and I am wondering if it is because of the link): https:    //community.       powerbi.com/t5/Desktop/Microsoft-PowerBI-Scripting-Python-Exceptions/td-p/850714  

2. In addition to the 4 paths mentioned in that link above, I also tried/tested the additiona of these paths as well: \lib\site-packages\Levenshtein and/or \lib\site-packages

3. Added a direct path to the module in the script itself using:

import sys

sys.path.append("[fullpath left out of post]\Levenshtein\__init__.py")

import Levenshtein as lv

 

Other notes:

1. The import statement and code run successfully in jupyter notebook that uses the same environment

2. Environment; Anaconda virtual environment running python 3.7.7

3. Levenshtein module installed in virtual environment using the following command:  conda install -c conda-forge python-levenshtein

4. i confirmed that in the .pbix file, the Python Scripting path under File/Options_and_Settings is pointing to the correct virtual environment path where Levenshtein is installed

5. In .pbix file, under File/Options_and_Settings/Options/CurrentFile/Privacy, the privacy level is set to "Ignore the Privacy level ..."

 

Many thanks to whoever might be able to guide me.

@Anonymous can you ensure that this post does not get labeled as spam?  This is my 3rd attempt.  First two posts never published because they are being labeled as spam for some reason.  Thanks

 

1 ACCEPTED SOLUTION
Richard917
Regular Visitor

My workaround for this was to install standard python (not anaconda) and point the pbix file to the non-anaconda instance.  Seems like Power BI does not work well with Anaconda. Bummer considering all my data science work is done there.  The desktop file now runs as expected.  When I publish to Power BI and try to schedule a refresh using the Personal Gateway, I get an error message that shows that Power BI is looking for the Anaconda installation.  Not sure why considering that the file itself points to the non-anaconda installation and Anaconda was removed from all Path variables. That's an issue for another post i guess.

View solution in original post

2 REPLIES 2
Richard917
Regular Visitor

My workaround for this was to install standard python (not anaconda) and point the pbix file to the non-anaconda instance.  Seems like Power BI does not work well with Anaconda. Bummer considering all my data science work is done there.  The desktop file now runs as expected.  When I publish to Power BI and try to schedule a refresh using the Personal Gateway, I get an error message that shows that Power BI is looking for the Anaconda installation.  Not sure why considering that the file itself points to the non-anaconda installation and Anaconda was removed from all Path variables. That's an issue for another post i guess.

Anonymous
Not applicable

@Richard917  - Thanks for the at the @mention.  

The platform scans for spam automatically and we monitor all flagged posts to determine whether or not the content should be unmarked. There are multiple variables the platform scans for and I have no way of knowing exactly what triggered your post to be flagged. Some common trigger items are copy and pasting content in and multiple edits. You should be good to go on this post. Thanks for being a part of the community!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.