It is currently not possible to import a Python library in Server Scripts, mainly for security reasons.
However, it is possible to import anything inside a custom application. You have to:
- Create a custom application that will be installed alongside Frappe, ERPNext, HRMS, etc.
- Add your dependencies (specific non-standard Python libraries) in the pyproject.toml file.
- Write the code in a file (that is currently in a server script)
- Call the code from outside: from a hook, as a REST API (when
frappe.whitelisted), from a server script (withfrappe.call), …