Install a library with an init script (legacy)
Databricks recommends defining libraries using cluster policies to provide custom configurations for compute environments. See Add libraries to a policy. Migrate all libraries installed with init scripts to use this pattern, because installing libraries using init scripts can lead to unexpected errors, such as "Module not found" failures during job execution.
This documentation has been retired and might not be updated. Databricks no longer recommends using init scripts to install libraries.
If your library requires custom configuration, you may not be able to install it using the workspace or cluster library interface. Instead, you can install the library using an init script.
Here is an example of an init script that uses pip to install Python libraries on a Databricks Runtime cluster at cluster initialization.
#!/bin/bash
/databricks/python/bin/pip install astropy