Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hi everyone,
I'm having some this error below while trying to use python script to learn pkl machine learning models within power bi:
I was re-install the microsoft .net framework with the latest version and also try to find any duplicated values within model.config file but there is none..
This below is my python scripts to enable it..
Do you know how to solve this issue? Thanks!
import pandas as pd
import pickle
from datetime import timedelta
# Load the model
with open("C:\Users\Downloads\hospital_los_model.pkl", "rb") as file:
model = pickle.load(file)
# Example test data (in production, pull this from a database or file)
test_data = pd.DataFrame({
'Age': [90],
'Gender': ['F'],
'Admission Date': [pd.Timestamp("2024-11-23 13:32:00")],
'Number of transfers': [2],
'Current ward': ['WARD7'],
# Add any other features your model expects
})
# Assume model has a predict method that returns LOS
predicted_los = model.predict(test_data)
# Add predictions to the DataFrame
test_data['Predicted LOS'] = predicted_los
test_data['Predicted Discharge'] = test_data['Admission Date'] + test_data['Predicted LOS'].apply(lambda x: timedelta(days=x))
# Output for Power BI
output = test_data[['Age', 'Gender', 'Admission Date', 'Number of transfers', 'Current ward', 'Predicted LOS', 'Predicted Discharge']]
Solved! Go to Solution.
Hi @heejinyune,
Thank you for reaching out to the Microsoft Fabric Forum Community.
You're seeing this error because Power BI can't find a needed component from the .NET Framework that's required to run your Python script. Even if you installed the latest version, it’s important to install the specific .NET Framework version 4.7.2 or 4.8, which Power BI works best with. Also, make sure that your Python is properly set up in Power BI by going to the Options and settings menu and checking the Python scripting path. Double-check that the needed Python packages like pandas and scikit-learn are installed. In your code, fix the file path by using double backslashes (\\) or a raw string (r"...") to avoid path errors.
Best regards,
Prasanna Kumar
Hi @heejinyune,
Just following up to see if updating the .NET Framework and reviewing your Python setup in Power BI resolved the issue. If you're still encountering any errors or need help troubleshooting further, please don’t hesitate to reach out we're here to help.
Best regards,
Prasanna Kumar
Hi @heejinyune,
Just checking in to see if installing the appropriate .NET Framework version and reviewing your Python setup in Power BI helped resolve the issue. If you’re still running into errors or need further assistance with the script or environment setup, feel free to let us know we’re happy to help.
Best regards,
Prasanna Kumar
Hi @heejinyune,
Thank you for reaching out to the Microsoft Fabric Forum Community.
You're seeing this error because Power BI can't find a needed component from the .NET Framework that's required to run your Python script. Even if you installed the latest version, it’s important to install the specific .NET Framework version 4.7.2 or 4.8, which Power BI works best with. Also, make sure that your Python is properly set up in Power BI by going to the Options and settings menu and checking the Python scripting path. Double-check that the needed Python packages like pandas and scikit-learn are installed. In your code, fix the file path by using double backslashes (\\) or a raw string (r"...") to avoid path errors.
Best regards,
Prasanna Kumar
Hi Prasanna Kumar!
Thanks for your reply!
When i reinstall .NET Framework with 4.8 it worked! Thanks 🙂