0

from flask-sqlalchemy import SQLAlchemy showing unresolved import error. But i already install flask sqlalchemy in cmd using pip install flask-sqlalchemy command.In python shell in command line sqlalchemy is importing normally there is no problem but in flask app its showing import error

    from flask import Flask, render_template

    from flask_sqlalchemy import SQLAlchemy


    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db'


     all_post=[
     {
    'title':'post1',
    'content':'content of post1',
    'author':'dipanjan'
     },
     {
    'title':'post2',
    'content':'content of post2'
     }
     ]

     @app.route('/posts')
     def posts():
     return render_template('posts.html', posts=all_post)

     @app.route('/')
     def home():
       return render_template('index.html')

     if __name__ =="__main__":   
        app.run(debug=True)
Pop_rapso
  • 1
  • 2
  • are you sure you've installed with pip3? https://stackoverflow.com/questions/14295680/unable-to-import-a-module-that-is-definitely-installed – Alexey Nikonov Mar 18 '21 at 10:33
  • sometimes this happen when you have python2 with pip and python3 with pip3 and you misuse them accidentally – Alexey Nikonov Mar 18 '21 at 10:34
  • i upgrade pip using "pip install --upgrade pip" this command But showing me this environment error please help me to solve this – Pop_rapso Mar 18 '21 at 12:57
  • Collecting pip Using cached pip-21.0.1-py3-none-any.whl (1.5 MB) Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 20.3.3 Uninstalling pip-20.3.3: Successfully uninstalled pip-20.3.3 ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Users\\pip-uninstall-tao9rdef\\pip.exe' Consider using the `--user` option or check the permissions. – Pop_rapso Mar 18 '21 at 12:58

1 Answers1

0

İf you use venv and you cant see your packages, go ypur venv path and run this code below:

pip freeze

and check your package you want

Ayse
  • 576
  • 4
  • 13