Install & Compatibility
Where this runs
tested against v0.78 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
libify
✓ import libify
✗ import libify
To use Libify, you need two types of notebooks: an 'importee' (the one providing functions) and an 'importer' (the one consuming them). The 'importee' notebook must end with a specific `libify.exporter` call to make its global scope available. The 'importer' notebook then uses `libify.importer` to load the target notebook as a module, allowing access to its defined functions and variables using dot notation.
# --- In the notebook to be imported (e.g., '/Users/my_user/my_functions') ---
# This cell must be the LAST cell in the notebook and contain ONLY this code.
def greet(name):
return f"Hello, {name} from imported notebook!"
def add(a, b):
return a + b
import libify
libify.exporter(globals())
# --- In the importing notebook (e.g., '/Users/my_user/main_workflow') ---
import libify
# The path should be relative to the Databricks workspace root or absolute DBFS path
my_module = libify.importer(globals(), '/Users/my_user/my_functions')
# Now you can access functions/variables defined in 'my_functions' notebook
message = my_module.greet("World")
print(message)
result = my_module.add(5, 3)
print(f"The sum is: {result}")
# Expected output in the importing notebook:
# Hello, World from imported notebook!
# The sum is: 8
Debug
Known issues
gotchaThe `dbutils.notebook.exit()` function must NOT be used in notebooks that are intended to be imported using `libify`. Its presence will prevent `libify` from properly exporting the notebook's global state.fixRemove any `dbutils.notebook.exit()` calls from 'importee' notebooks.
affects: All
gotchaThe `libify.exporter(globals())` call in the 'importee' notebook must be the absolute last cell and contain ONLY that specific code. Any other code or comments in that final cell will prevent correct module export.fixEnsure the last cell of the 'importee' notebook contains only `import libify; libify.exporter(globals())`.
affects: All
deprecatedDatabricks introduced 'Files in Repos' functionality (available since late 2021 / Feb 2023 update) which allows direct import of Python files as modules. This native feature might offer a more streamlined approach for new projects compared to `libify`, especially for standard Python modules.fixFor new projects or refactoring, evaluate using Databricks 'Files in Repos' for native Python module imports instead of `libify`.
affects: < 0.78 (consider for new projects)
gotchaOn Databricks Community Cloud, the installation and setup for `libify` needs to be rerun each time a cluster is created or restarted for imports to function correctly.fixInclude `libify` installation and the importer notebook's initial `import libify` as part of your cluster initialization scripts or rerun manually after restarts.
affects: All (specific to Databricks Community Cloud)
Upgrade
Version history
0.78latest on PyPI · released Sep 22, 2020
Audit
Dependencies
No dependency data recorded yet.