public static void detachPythonLibrary(final Module module, final String libraryName) {
    final ModifiableModelsProvider modelsProvider = ModifiableModelsProvider.getInstance();
    ApplicationManager.getApplication().runWriteAction(() -> {
      // remove the library
      final ModifiableRootModel model = modelsProvider.getModuleModifiableModel(module);
      OrderEntry entry = OrderEntryUtil.findLibraryOrderEntry(model, libraryName);
      if (entry == null) {
        modelsProvider.disposeModuleModifiableModel(model);
      }
      else {
        model.removeOrderEntry(entry);
        modelsProvider.commitModuleModifiableModel(model);
      }
    });
  }
public static void detachPythonLibrary(final Module module, final String libraryName)