cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Community Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Uninstalling a preinstalled python package from Databricks

KrishZ
Contributor

[Datasets](https://pypi.org/project/datasets/) python package comes preinstalled on databricks clusters. I want to uninstall it or completely prevent it's installation when I create/start a cluster.

I couldn't find any solution on stackoverflow.
And I have tried !pip uninstall datasets in a notebook. It throws the below error

```
Found existing installation: datasets 2.12.0
Not uninstalling datasets at /databricks/python3/lib/python3.10/site-packages, outside environment /local_disk0/.ephemeral_nfs/envs/pythonEnv-some-long-uu-id-I-have-hidden
Can't uninstall 'datasets'. No files were found to uninstall.
```

Can someone guide on what to do here ?

 

2 REPLIES 2

Kaniz_Fatma
Community Manager
Community Manager

Hi @KrishZTo prevent Python packages from being installed when creating or starting a cluster, you can modify the cluster configuration by setting the spark.databricks.cluster.profile to serverless and spark.databricks.repl.allowedPyImportPrefixes To an empty string. This will turn off the installation of Python packages and prevent the execution of any Python code. Alternatively, you can use init scripts to remove any installed packages.

To uninstall a specific package, you can use the pip uninstall  command followed by the package name.

To uninstall the legacy Databricks CLI, you can use the command. pip uninstall databricks-cli.

sean_owen
Honored Contributor II
Honored Contributor II

@Kaniz_Fatma note that you can't actually uninstall packages in the runtime with pip.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!