0

I'm trying to create a Flask API that will receive an ID by GET APand return data coming from Big Query.

    from google.cloud import bigquery
    from google.oauth2 import service_account

    credentials = service_account.Credentials.from_service_account_file(SERVICE_FILE)

    project_id = PROJECT_ID

    client = bigquery.Client(credentials= credentials,project=project_id)      

    query_job = client.query("""
    SELECT *
    FROM TABLES
    LIMIT 1000 """)

    self.df = query_job.result().to_dataframe()

Everything is working all right when I run this code from a Jupyter notebook. But as soon as I try to run it from my Flask App in Visual Studio code, I am getting the following error :

google.api_core.exceptions.RetryError: Deadline of 600.0s exceeded while calling target function, last exception: HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

I'm working with Python 3.8 and Windows 11. Do you have any ideas of what I'm missing here ?

Thank you !

jeremieb
  • 17
  • 5
  • Are the jupyter notebook and flask app's virtual environments same ? – Anshuman Tiwari Oct 06 '22 at 10:08
  • Yes they are. I tried to created a new env, and enverything is working on Jupyter but not on Visual studio with Flask . – jeremieb Oct 06 '22 at 13:55
  • Does this [thread](https://stackoverflow.com/questions/54135206/requests-caused-by-sslerrorcant-connect-to-https-url-because-the-ssl-module) solve your problem? Let me know if that helps. – kiran mathew Oct 10 '22 at 11:09

0 Answers0