Forum Discussion

clbfkp's avatar
clbfkp
Regular Visitor
4 months ago
Solved

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?

 

7 Replies

  • 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!

     

  • 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

  • v-priyankata's avatar
    v-priyankata
    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.

     

  • 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's avatar
    v-priyankata
    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.