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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

@heaher_iTalent 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.

heaher_iTalent
Administrator
Administrator

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.