pythonsqlalchemyazure-databrickspypi

Databricks Error : ModuleNotFoundError: No module named 'sqlalchemy'


I am completely new to this Databricks.

In Databricks i have tried running the following packages in its python notebook

# Library Section
import psycopg2
import pandas as pd
import numpy as np
import sqlalchemy
from sqlalchemy import create_engine
from io import StringIO
import os
import smtplib
import time
from email.mime.text import MIMEText
import datetime

All these packages are running fine when i am running the cell individually. But when i am trying to run the packages on the auto schedule mode, its giving the error

ModuleNotFoundError: No module named 'sqlalchemy'
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<command-4076398358532638> in <module>
      8 import pandas as pd
      9 import numpy as np
---> 10 import sqlalchemy
     11 from sqlalchemy import create_engine
     12 from io import StringIO

ModuleNotFoundError: No module named 'sqlalchemy'

Absolutely no idea what is this problem all about. Can someone please help me with this.

Edit 1: i installed the following libraries in Databricks

  1. psycopg2
  2. sqlalchemy
  3. flask_SQLAlchemy

but still the same problem


Solution

  • When you say I had installed the following libraries in Databricks, How exactly have you installed sqlalchemy library?

    By default, Databricks clusters will not have sqlalchemy library installed on the runtime selected.

    enter image description here

    You need to install the sqlalchemy library explicitly and run the above command.

     pip install SQLAlchemy
    

    enter image description here