ImportError: No module named sqlalchemy

前端 未结 14 1440
渐次进展
渐次进展 2020-12-08 03:45

I\'m unable to find a module in python ,though easy_install says its already installed. Any idea how to resolve this isseue?

$ python -c \"from flaskext.sql         


        
相关标签:
14条回答
  • 2020-12-08 04:23

    first install the library

    pip install flask_sqlalchemy 
    

    after that

    from flask_sqlalchemy import SQLAlchemy
    

    put this in app.py file to get the access of database through SQLAlchemy

    0 讨论(0)
  • 2020-12-08 04:24

    Okay,I have re-installed the package via pip even that didn't help. And then I rsync'ed the entire /usr/lib/python-2.7 directory from other working machine with similar configuration to the current machine.It started working. I don't have any idea ,what was wrong with my setup. I see some difference "print sys.path" output earlier and now. but now my issue is resolved by this work around.

    EDIT:Found the real solution for my setup. upgrading "sqlalchemy only doesn't solve the issue" I also need to upgrade flask-sqlalchemy that resolved the issue.

    0 讨论(0)
  • 2020-12-08 04:28

    Very late to the party but hopefully this will help someone, was in the same situation for about a hour without any of the solutions mentioned above working. (On a Windows 10 machine).

    In the Settings/Preferences dialog (Ctrl+Alt+S), from the side menu select Project: | Project Interpreter.

    Check which packages you currently have installed (You need SQLAlchemy and Flask-SQLAlchemy). Double click on any package name, an 'Available Packages' menu will open.

    Search for the missing package(s) and click install.

    0 讨论(0)
  • 2020-12-08 04:29

    I'm new comer, use python 3.8 and met the same problem. I installed with pip instead of pip3 because i thought the pip installer is the same for python2 and python3 so this is proper installation

    pip3 install flask_sqlalchemy

    0 讨论(0)
  • 2020-12-08 04:30

    I just experienced the same problem using the virtual environment. For me installing the package using python from the venv worked:
    .\venv\environment\Scripts\python.exe -m pip install flask-sqlalchemy

    0 讨论(0)
  • 2020-12-08 04:34

    Solution for me was to use:

    from flask_sqlalchemy import SQLAlchemy
    

    instead of

    from flask.ext.sqlalchemy import SQLAlchemy
    
    0 讨论(0)
提交回复
热议问题