cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to install AI library aif360 on databricks notebook

ahmedE_
New Contributor II

Hello,

I'm trying to install a library called aif360 on the databricks notebook. However, I get error that tkinter is not installed.

I tried installing tk and tk-tools, but still the issue remains.

Any idea on what solution we can use?

no way to instal tkinter 

I also tried installing the libraries through the cluster settings, still doesn't work.

6 REPLIES 6

Anonymous
Not applicable

@Ahmed Elghareeb​ :

The aif360 package requires a GUI library like tkinter for some of its visualization functionalities. However, it is not recommended to install GUI libraries on Databricks since it is a cloud-based platform and there is no display available. You can still use the aif360 package on Databricks, but you will need to avoid using the visualization functionalities that require tkinter. If you still need to use the visualization functionalities, one workaround is to install the required libraries on your local machine and run the visualization code from there.

If you still encounter issues with the installation, try installing aif360 and its dependencies using a Python wheel file instead of using pip. You can download the wheel file from the aif360 GitHub page (https://github.com/Trusted-AI/AIF360) and then upload it to your Databricks workspace. Then, install the wheel file using the "Upload Python Egg or PyPI Package" option in the "Libraries" tab.

ahmedE_
New Contributor II

Thanks @Suteja Kanuri​ for your answer. Indeed I'm aware of the GUI situation. In fact, I have no intention of using the GUI feature, however, tkinter is imported on a module level. Even if I'm not calling Tkinter code at all, since the import is in the same file as other code that I'm calling, then it's gonna raise an exception.

so, the question is.. is there a way to install Tkinter when I'm not planning to use it?

Anonymous
Not applicable

@Ahmed Elghareeb​ : Can you try installing using the below command

pip install python-tk

ahmedE_
New Contributor II

@Suteja Kanuri​ ​ I get a weird error that the library doesn't exist. I'm attaching a screenshot.

Anonymous
Not applicable

@Ahmed Elghareeb​ : Providing you 2 options here, please see what works for you.

Option 1:

!pip install tk

This should install the necessary dependencies for python-tk without actually installing the python-tk package itself.

Option 2:

  1. Create a new cluster in Databricks.
  2. Under the "Advanced Options" section, select the "Init Scripts" tab.
  3. Add a new init script with the following content:
apt-get update
apt-get install -y python3-tk```
 

-Save and launch the cluster.

-Once the cluster is up and running, you should be able to import tkinter in your notebook.

This init script installs the required package for tkinter to work on Databricks.

Vartika
Databricks Employee
Databricks Employee

Hi @Ahmed Elghareeb​ 

Thank you for your question! To assist you better, please take a moment to review the answer and let me know if it best fits your needs.

Please help us select the best solution by clicking on "Select As Best" if it does.

This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group