I have a REST API that I want to deploy on pythonanywhere. I'm using Flask for the app. It uses an API key I am trying to hide in a .env file. I get this error message:
2022-10-31 05:09:53,356: Error running WSGI application
2022-10-31 05:09:53,356: ModuleNotFoundError: No module named 'dotenv'
2022-10-31 05:09:53,356: File "/var/www/vbosu_pythonanywhere_com_wsgi.py", line 10, in <module>
2022-10-31 05:09:53,357: from dotenv import load_dotenv
I attempted to use the only guidance I can find on this, from here and here. Nothing is working. Here is the code in my wsgi.py file:
import sys import os from dotenv import load_dotenv
project_folder = os.path.expanduser('~/home/vbosu/mysite') load_dotenv(os.path.join(project_folder, '.env'))
project_home = '/home/vbosu/mysite' if project_home not in sys.path: sys.path.insert(0, project_home)
ENDPOINT = os.getenv("ENDPOINT") APP_ID = os.getenv("APP_ID")
from app import app as application # noqa
Does anyone have any idea what I'm missing here?