0
class lume:
    
    import requests 
    import pandas as pd    
    
    def __init__(self,start_date,end_date):
        self.start_date=start_date
        self.end_date=end_date
        
         #=============overall lp summary =============================
    def Summary_LP(self):
        #format (YYYY-mm-dd)
        summary_lp=requests.get("url" +self.start_date+"&end="+self.end_date)
        summary_lp =summary_lp.json()
        df_summary_lp=pd.read_json(summary_lp)

        return df_summary_lp

When I call the class, i get the following message:

NameError: name 'requests' is not defined
Kemp
  • 3,467
  • 1
  • 18
  • 27
  • 1
    You really should be imported the packages at the start of the file, not inside a class. Especially just free-floating in the class like that, it's likely that the imports are never actually being performed. – Kemp Aug 10 '21 at 13:36
  • Does this answer your question? [using import inside class](https://stackoverflow.com/questions/38087060/using-import-inside-class) – Wombatz Aug 11 '21 at 00:22

0 Answers0