3

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.

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42
kumar
  • 43
  • 4
  • have you install graphframes ? check this can help https://stackoverflow.com/questions/50286139/no-module-named-graphframes-jupyter-notebook. Installation https://pypi.org/project/graphframes/ – Avinash Dalvi Dec 13 '19 at 13:21

3 Answers3

2

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.

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42
0

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

0

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

J0ker98
  • 447
  • 5
  • 18