Issue
maybe it looks strange, but I really don't understand what's wrong with this app. I started learning Flask and in the beggining of my path I received this error. Thanks in advance for helping! And if u can suggest pls what other databases I can use with Flask
>>> from app import db
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Admin\PycharmProjects\Render\app.py", line 1, in <module>
from flask import Flask, render_template, request, url_for
ModuleNotFoundError: No module named 'flask'
This is my structure:
- Project(folder)
- app.py
- database.db
- venv(folder)
- templates (folder)
- static (folder)
- pycache (folder)
- .idea (folder)
This is code:
from flask import Flask, render_template, request, url_for
from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin
import os
PHOTO = os.path.join('static')
app = Flask(__name__) #, template_folder='templates')
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
db = SQLAlchemy(app)
app.config['SECRET_KEY'] = 'thisisasecretkey'
app.config['UPLOAD_FOLDER'] = PHOTO
full_filename = os.path.join(app.config['UPLOAD_FOLDER'], 'test.jpg')
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(20), nullable=False)
password = db.Column(db.String(80), nullable=False)
I tried import database structure from my app(flask) to the database file, I have appr. 50 links opened and didn't find anything. pip install, recreating enviroment and all these stuff
Here is the screen with "pip list"
Solution
I see the screenshot you might do this in Python Console?if in Python Console,it is a pure python environment, not include your app package,you need finish the code, and use python app.py
to run it.
Answered By - Auraxc Answer Checked By - Katrina (WPSolving Volunteer)