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

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
davidfabricdev
Regular Visitor

Please help, how can I use Semantic Link Labs library in a notebook inside a Fabric Pipeline?

I wish to use the funtions in semantic link labs in a PySpark notebook which will be an activity within a Fabric pipeline;

 

So, to start here is the notebook, please excuse the distracting commented-out lines where I have been experimenting.  I am running the code inside the notebook, no pipeline involved at this stage, and it works fine.  Note (highlighted) default environment and %pip install.

 

davidfabricdev_0-1748617802795.png

 

If I run this inside a pipeline I get this error;

 

davidfabricdev_1-1748618009244.png

 

Fair enough, I need to work around the %pip install command which I can't use in this context.  So after some googling I have loaded the semantic link labs library into an environment as a public library.

 

davidfabricdev_2-1748618183607.png

 

Now I change my notebook to use the new environment and remove the %pip install command;

 

davidfabricdev_3-1748618339806.png

 

When I run the pipeline again I get this error;

 

davidfabricdev_4-1748618678535.png

 

If I run %pip list the library is indeed loaded.

 

It seems that I simply don't understand how to reference it in my notebook.

 

Now that the library is loaded into the environment do I also need to run an import command?  If so, what is the name of the thing I need to import?  If I don't need to import in the notebook then what would the correct syntax be for the command "

labs.admin.scan_workspaces()"
 
This is driving me mad though I'm sure the answer is very simple.  Please help!
 
Thank you in advance.
1 ACCEPTED SOLUTION

Hi @davidfabricdev,

You're correct that Python module names can't contain hyphens (-). The - is valid in a package name (e.g., azure-core when installed via pip), but not in an import statement. The actual module you import often uses underscores or nested paths. For example: The PyPI package azure-core is installed via %pip install azure-core, but to import it, you should use "import azure.core as azc".

 

So if you're trying something like import azure_core and it fails, it's expected because azure_core isn’t a valid module. Instead, try checking the actual import path used within the package.

Here are two way to find the correct import name:

* Use "pip show <package-name>" . It will show you a Location and Name. You can browse to that path and look for subfolders or modules inside, for example, a folder like azure/core.

* Check with Python.

import importlib.util

def try_import(mod_name):
spec = importlib.util.find_spec(mod_name)
print(f"{mod_name}: {'Found' if spec else 'Not found'}")

try_import("azure.core")
try_import("azure_core")
try_import("semantic_link_labs")
try_import("semantic.link.labs")

This lets you test different paths to see which one is actually importable.

 

Best Regards,

Hammad.

View solution in original post

10 REPLIES 10
v-mdharahman
Community Support
Community Support

Hi @davidfabricdev,

Thanks for reaching out to the Microsoft fabric community forum.

You're right that %pip magic commands work in interactive notebooks but are not supported when the notebook runs as part of a Fabric pipeline. You're also correct in trying to use a custom environment with the library pre-installed.

From what you've described and shown you’ve successfully added semantic-link-labs as a public library in your environment (FCMEnvironment). %pip list command confirms the library is present. But after all this you are still seeing ModuleNotFoundError during pipeline execution.

To resolve it, the key issue is likely with the import statement or the module name you're using in the notebook.

Even though the library is installed in the environment, you still need to import it manually in your code. The correct import for the semantic-link-labs package is "import semantic_link_labs as labs". Then you can call "labs.admin.scan_workspaces()".

 

Make sure %pip install ... is fully removed from the notebook. And set the notebook environment to your custom one (FCMEnvironment), which you've already done. Now add the import semantic_link_labs as labs line at the top of your notebook. Then call your function as labs.admin.scan_workspaces().

 

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.
Community Support Team

 

If this post helps then please mark it as a solution, so that other members find it more quickly.

Thank you.

Many thanks for your reply Hammad.

 

Unfotunately I still can't get my notebook to work so any further help you can provide will be greatly appreciated.

 

Here is the error when I run the notebook directly;

 

davidfabricdev_0-1748879984935.png

 

And here is what happens when I run it in a pipeline;

 

davidfabricdev_1-1748881006292.png

And just to confirm, here is the environment;

 

davidfabricdev_2-1748881138917.png

 

Do you have any further thoughts on this?  I'm also wondering if there is a definitive way to discover the the import name of a package?

 

Thanks

David

The correct import statement for the semantic labs library should be

 

import sempy_labs as labs

Hi @davidfabricdev,

Even after going through all trouble-shooting steps the issue still persists, you can reach out to Microsoft Support Team by raising a ticket with Microsoft Support.

Please refer below link on how to raise a contact support or support ticket.
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn

 

Best Regards,

Hammad.

Hi @davidfabricdev,

I wanted to follow up on our previous conversation. Has your issue been resolved or were you able to raise a support ticket with Microsoft Fabric Support?

 

Your feedback would be greatly appreciated, as it can help us better understand and address similar issues in the community.

Thank you.

Not as yet, I've not yet followed up with Microsoft.  Are you are able to answer my question about finding the import name of a package, any package, not just the one I am trying to use here?

 

For example, azure-core (at the bottom of the list below)

davidfabricdev_0-1749214755362.png

when I run "import azure_core as azc" I also get the module not found error

davidfabricdev_1-1749214861766.png

It seems that the wider problem is that I can't import modules with a hyphen in their name.  Using the hyphen causes a syntax error and replacing with underscore results in module not found.  I suspect the issue isn't specific to the semantic link labs package.  Is there a way to trouble shoot this issue?

So just to confirm the specific problem, from the %pip list results, I can import any module which does not contain a hyphen, but I can not import any of the modules which do contain a hyphen, even if I use functions like "__import__" or "importlib.import_module".  There must be a way to import these modules.

Hi @davidfabricdev,

You're correct that Python module names can't contain hyphens (-). The - is valid in a package name (e.g., azure-core when installed via pip), but not in an import statement. The actual module you import often uses underscores or nested paths. For example: The PyPI package azure-core is installed via %pip install azure-core, but to import it, you should use "import azure.core as azc".

 

So if you're trying something like import azure_core and it fails, it's expected because azure_core isn’t a valid module. Instead, try checking the actual import path used within the package.

Here are two way to find the correct import name:

* Use "pip show <package-name>" . It will show you a Location and Name. You can browse to that path and look for subfolders or modules inside, for example, a folder like azure/core.

* Check with Python.

import importlib.util

def try_import(mod_name):
spec = importlib.util.find_spec(mod_name)
print(f"{mod_name}: {'Found' if spec else 'Not found'}")

try_import("azure.core")
try_import("azure_core")
try_import("semantic_link_labs")
try_import("semantic.link.labs")

This lets you test different paths to see which one is actually importable.

 

Best Regards,

Hammad.

Hi @davidfabricdev,
We noticed there hasn’t been any recent activity on this thread. If your issue is resolved, marking the correct reply as a solution would be a big help to other community members.
If you still need support, just reply here and we’ll pick it up from where we left off.

 

Best Regards,

Hammad.

Hi @davidfabricdev,
I just wanted to follow up on the thread. If the issue is resolved, it would be great if you could mark the solution so other community members facing similar issues can benefit too.
If not, don’t hesitate to reach out, we’re happy to keep working with you on this. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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