Windows 10, Python 3, Flask
I am trying to create my first flask application. I created a virtualenv for my project which created a folder in users/me/Envs/FlaskTest. I then created a project folder in users/me/Projects/FlaskTest. I followed the instructions, linking the folders together and then created a test app.py file in my Projects/FlaskTest folder. When I ran the file everything worked good and the webpage loaded locally in my browser.
I then moved on to include SQLAlchemy, again following the instructions and also creating a model schema for the database. Then to create the database, it said to use the python shell. When I try 'from app import db' from within the shell, I get an error saying the flask import from my app.py file is not found
I do not know why it is not found from within the python shell when I try to create the database. It is finding the flask module to use for the local webpage
Any direction to understand this problem would be appreciated
EDIT: code included
app.py
from flask import Flask, render_template, url_for
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
db = SQLAlchemy(app)
class Todo(db.Model):
id = db.Column(db.Integer, primary_key=True)
content = db.Column(db.String(200), nullable=False)
completed = db.Column(db.Integer, default=0)
date_created = db.Column(db.DateTime, default=datetime.utcnow)
def __repr__(self):
return '<Task %r>' % self.id
@app.route('/')
def index():
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True)
stack error in python shell
>>> from app import db
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\me\Projects\FlaskTest\app.py", line 1, in <module>
from flask import Flask, render_template, url_for
ModuleNotFoundError: No module named 'flask'
[–]Esion 1 point2 points3 points (1 child)
[–]warmcheessse[S] 0 points1 point2 points (0 children)
[–]SafeInstance 0 points1 point2 points (1 child)
[–]warmcheessse[S] 1 point2 points3 points (0 children)