kumar
kumar

Reputation: 43

ImportError: No module named 'graphframes' databricks

I am trying to import graphframes in to my databricks notebook

    from graphframes import *     

but failed with following error message

ImportError: No module named 'graphframes'

How can I add/import in to databricks notebook, any help appreciated.

Upvotes: 3

Views: 3136

Answers (3)

CHEEKATLAPRADEEP
CHEEKATLAPRADEEP

Reputation: 12768

Note: By default, "graphframes" is not installed on the databricks.

You need to install the package explicitly.

You can install the packages in different methods.

Method1: Installing external packages using pip cmdlet.

Syntax: %sh /databricks/python3/bin/pip install <packagename>

%sh
/databricks/python3/bin/pip install graphframes

enter image description here

Method2: Using Databricks library utilities

Syntax:

dbutils.library.installPyPI("pypipackage", version="version", repo="repo", extras="extras")
dbutils.library.restartPython()  # Removes Python state, but some libraries might not work without calling this function

To install graphframes using databricks library utilities use the below command.

dbutils.library.installPyPI("graphframes") 

enter image description here

Tried the examples available in this article GraphFrames Documentation.

Notebook output:

enter image description here

Hope this helps.

Upvotes: 2

J0ker98
J0ker98

Reputation: 457

You need to install the graphframes module by opening your terminal and typing pip install graphframes

Upvotes: 0

kolja cheesch
kolja cheesch

Reputation: 28

graphframes is not default dependency with python. You should install this dependency.

Upvotes: 0

Related Questions