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
clbfkp
Regular Visitor

Fabric User Define Functions

I'm attempting to create a user defined function as a proof of concept.  I've selected the library I want from the dropdown (python-pptx) but still receive an error when I try to import and use it as if it is not recoginizing the full name.  Suggestions to fix or a work-around I can use for now?

clbfkp_0-1774882030323.png

 

2 ACCEPTED SOLUTIONS
arabalca
Resolver II
Resolver II

Hi @clbfkp 

This is a fairly common behavior in Fabric and it’s related to how Library Management vs the active notebook session works.

Even if you add the library from the menu, it doesn’t get injected automatically into the current session, which is why you’re seeing import errors or incorrect module resolution.

Try this:

1.Quick solution (for PoC / testing)

  • Install it directly in the notebook using pip to install python-pptx.

Thenyou should be able to import it with:

from pptx import Presentation

2.Proper solution (recommended)
For a stable setup:

  • Add python-pptx (with the hyphen) in the Environment
  • Publish the Environment
  • Attach it to the notebook
  • Start a new session (this is key — re-running is not enough)

3. How to verify installation

You can check it using pip show python-pptx.

 

If it doesn’t appear, it means it’s not installed in the current session, even if it shows in the UI.

 

Take a look and try this.

If it still fails, let me know the exact error you’re getting.

If this helps solve your problem, I’d appreciate it if you could mark it as the accepted solution and give it a like
Thanks!

View solution in original post

This is a user defined function, not a standard notebook.  Reading some of the Microsoft documentation, it looks like I am unable to pip install libraries and must go through the library manager.  

 

Error is "Library "pptx" is not added in library management, please add it before publishing.PythonIntellisenseProvider"  
 
I have tried earlier versions of the library and others, such as matplotlib, install with out issue.
 

View solution in original post

7 REPLIES 7
v-priyankata
Community Support
Community Support

Hi @clbfkp 

Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.

stoic-harsh
Resolver II
Resolver II

Hey @clbfkp,

The error occurs because the package name and the module name for this library are different. This is common in Python.

# You install it as:
pip install python-pptx
--------------------------------
# But you import it in code as:
import pptx, or
from pptx import Presentation

The "python-" prefix in the PyPI is just a naming convention used by the author. It simply tells that it is a Python library. Module name inside the package is "pptx", which is what Python looks for when you write an import statement.

Same pattern is seen in other popular libraries, for example, python-dotenv is imported as dotenv, pillow is imported as PIL, scikit-learn as sklearn.

Hope this helps!

v-priyankata
Community Support
Community Support

Hi @clbfkp 

Thank you for reaching out to the Microsoft Fabric Forum Community.

@Aparnaa_MS @arabalca Thanks for the inputs.

I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.

 

arabalca
Resolver II
Resolver II

Hi @clbfkp 

If my comment helped solve your question,  it would be great if you could mark it as the accepted solution. It helps others with the same issue and it also motivates me to keep contributing.

Thanks a lot. I really appreciate it

Aparnaa_MS
Advocate II
Advocate II

Hi @clbfkp ,

 

Echoing what @arabalca mentioned — installing the library directly within a Fabric Notebook using `%pip install python-pptx` is a valid and quick approach, especially for POC scenarios where you just need to unblock yourself fast.

A couple of additional things from my own testing:

- Double-check the publish status before running your function. Even after adding the library via Library Management, make sure the publish has fully completed and a success confirmation is shown — it's easy to assume it went through when it actually didn't.

- Try a different version of python-pptx: Try specifying a stable older version of python-pptx instead of the latest, as newer versions sometimes have platform-specific dependencies that may not be compatible with the Fabric runtime environment
I tested this myself — after switching to an alternate version and publishing, the code ran successfully even though a warning was still displayed in the editor.

Hope this contributes to solving your error.

Thanks!

 

arabalca
Resolver II
Resolver II

Hi @clbfkp 

This is a fairly common behavior in Fabric and it’s related to how Library Management vs the active notebook session works.

Even if you add the library from the menu, it doesn’t get injected automatically into the current session, which is why you’re seeing import errors or incorrect module resolution.

Try this:

1.Quick solution (for PoC / testing)

  • Install it directly in the notebook using pip to install python-pptx.

Thenyou should be able to import it with:

from pptx import Presentation

2.Proper solution (recommended)
For a stable setup:

  • Add python-pptx (with the hyphen) in the Environment
  • Publish the Environment
  • Attach it to the notebook
  • Start a new session (this is key — re-running is not enough)

3. How to verify installation

You can check it using pip show python-pptx.

 

If it doesn’t appear, it means it’s not installed in the current session, even if it shows in the UI.

 

Take a look and try this.

If it still fails, let me know the exact error you’re getting.

If this helps solve your problem, I’d appreciate it if you could mark it as the accepted solution and give it a like
Thanks!

This is a user defined function, not a standard notebook.  Reading some of the Microsoft documentation, it looks like I am unable to pip install libraries and must go through the library manager.  

 

Error is "Library "pptx" is not added in library management, please add it before publishing.PythonIntellisenseProvider"  
 
I have tried earlier versions of the library and others, such as matplotlib, install with out issue.
 

Helpful resources

Announcements
FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

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.

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 Fabric Update Carousel

Fabric Monthly Update - March 2026

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