Forums

ImportError when running Flask script

So I get an import error when running a flask script on a free account, any way to fix this

python app.py
Traceback (most recent call last):
File "app.py", line 2, in <module>
from scripts.employees import getEmployees
ImportError: No module named scripts.employees

My app.py:

from flask import Flask, render_template, request
from scripts.employees import getEmployees
from scripts.schedule import getSchedule

app = Flask(__name__)

@app.route('/')
def index():
    employeelist = getEmployees()
    return render_template('index.html', employeelist = employeelist)

@app.route('/', methods=["POST"])
def get_schedule():
    if request.method == "POST":
        employeelist = getEmployees()
        employeename = request.form["employeename"]

        working_days, working_hours = getSchedule(employeename)
        work_data = zip(working_days, working_hours)

        return render_template('rooster.html',
            employeename = employeename,
            employeelist = employeelist,
            work_data = work_data)

if __name__ == '__main__':
    app.run(debug=True)

that sounds like your working directory is not what you expect. See this. Try changing your working directory for your webapp under the PythonAnywhere web tab.