通过Python命令和dbutils在Databricks上安装Maven库

2024-07-07 06:52:30 发布

您现在位置:Python中文网/ 问答频道 /正文

在Databricks上,如果尚未安装Maven库,我希望通过Python笔记本中的命令安装它

如果它是Python PyPI库,我将执行以下操作:

# Get a list of all available library 
library_name_list = dbutils.library.list()
# Suppose the library of interest was "scikit-learn"
if "scikit-learn" not in library_name_list:
  # Install the library 
  dbutils.library.installPyPI("scikit-learn")

如何对Maven库“com.microsoft.azure.kusto:spark kusto connector:2.0.0”执行相同操作,即检查是否已安装,如果未安装,则安装

我可以通过“集群”使用UI安装Maven库->;“图书馆”->;“安装新的”->;“Maven”。但我希望通过脚本以编程方式完成它


Tags: ofthename命令gtpypilibrary笔记本
1条回答
网友
1楼 · 发布于 2024-07-07 06:52:30

Note: Library utilities (dbutils.library.installPyPI("")) allow you to install Python libraries and create an environment scoped to a notebook session.

以下是以编程方式从maven存储库安装库的步骤:

You can use Databricks CLI to install maven libraries in Azure Databricks.

步骤1:从maven坐标,您可以转到maven存储库,选择您要查找的版本,并注意依赖关系(groupId、artifactId和version)

enter image description here

步骤2使用databricks CLI获取群集ID

要获取群集ID:databricks clusters list

enter image description here

步骤3:使用下面的Databricks CLI命令在Databricks中安装“com.microsoft.azure.kusto:spark-kusto-connector:2.0.0

语法:databricks libraries install cluster-id "Cluster ID" maven-coordinates "GroupId:ArtifactId:Version" (i.e.org.jsoup:jsoup:1.7.2)

要使用databricks CLI安装maven库:databricks libraries install cluster-id "1013-095611-mazes551" maven-coordinates "com.microsoft.azure.kusto:spark-kusto-connector:2.0.0"

要检查群集上的安装库:databricks libraries list cluster-id "1013-095611-mazes551"

enter image description here

有关在Azure Databricks中安装软件包的不同方法,请参阅:How to install a library on a databricks cluster using some command in the notebook?

相关问题 更多 >