Forum Discussion
library installation issue pyenv vs cluster-env
- Anonymous1 year ago
Hi smpa01 ,
You're currect, using a custom environment does introduce performance overhead:
Library publishing takes approximately 20 minutes, as the environment needs to be built and distributed across the cluster. Session startup can take around 5 minutes, especially if the environment includes multiple or large dependencies.
To manage this efficiently, we use hybrid approach:
- Use the custom environment for stable, shared libraries that are unlikely to change frequently (e.g., termcolor, numpy, pandas). This ensures consistency across notebooks without frequent rebuilds.
- Install fast-changing or notebook-specific libraries (like aiofiles) using %pip install in the first cell of the notebook. This avoids the need to republish the entire environment for every update.
If this post helps, then please consider to Accept as the solution to help the other members find it more quickly and a kudos would be appreciated.
Thank you.
Hi smpa01 ,
Thank you for reaching out Microsoft fabric community forum and providing detailed context, including links and screenshots it’s very helpful.
You are correct in observing that libraries installed via %pip install is only available within the current notebook session. In Microsoft Fabric, %pip performs a session-scoped installation, which means it will not persist or carry over to other notebooks or Spark jobs, even within the same workspace.
Libraries like requests or aiohttp may appear persistent because they are pre-installed in Fabric’s base Spark runtime.
To achieve your goal of using termcolor (or any other third-party package) across multiple notebooks consistently, we recommend installing the package as a workspace library. Here’s how:
- Download the .whl file for termcolor from PyPI.
- Upload it to your workspace via OneLake or the Library Management UI.
- Attach it via Workspace > Libraries > Add.
Once attached, it will be accessible to all notebooks and Spark jobs within that workspace.
Hope this helps. Please reach out for further assistance.
If this post helps, then please consider to Accept as the solution to help the other members find it more quickly and a kudos would be appreciated.
Thank you.
- smpa011 year agoCommunity Champion
Can you give me a screnshot of this part
3. Attach it via Workspace > Libraries > Add.
- Anonymous1 year agoNot applicable
Hi smpa01 ,
Here is the screenshot showing how to attach a .whl file via:
Workspace > Libraries > Add > Custom Library
As shown above, after uploading the library, make sure to click “Publish” (top right) to finalize the changes. Only then will the custom library become available across all notebooks in the workspace.
Thank you.
- smpa011 year agoCommunity Champion
The exact screen is not available to me cause Workspace > Libraries > Add > Custom Library is blocked by IT.
However, I can do probaly the same thing by creating a custom environment and by uploading the .whls there. I can attach the custom env to all my notebooks.
However,
do I understand
that I still need to run `%pip install termcolor` on the top cell of the notebook(NB1) (I think that is the case)
or
if it is once installed, it is automatically available in other notebooks (simply `import termcolor`) as well as any other subsequest execution of NB1 without needing `%pip install termcolor` in the top cell (desired).