ImportError: No module named sqlalchemy

前端 未结 14 1438
渐次进展
渐次进展 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:12

    On Windows 10 @ 2019

    I faced the same problem. Turns out I forgot to install the following package:

    pip install flask_sqlalchemy
    

    After installing the package, everything worked perfectly. Hope, it helped some other noob like me.

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

    Install Flask-SQLAlchemy with pip in your virtualenv:

    pip install flask_sqlalchemy
    

    Then import flask_sqlalchemy in your code:

    from flask_sqlalchemy import SQLAlchemy
    
    0 讨论(0)
  • 2020-12-08 04:14

    Probably a stupid mistake; but, I experienced this problem and the issue turned out to be that "pip3 install sqlalchemy" installs libraries in user specific directories.

    On my Linux machine, I was logged in as user1 executing a python script in user2's directory. I installed sqlalchemy as user1 and it by default placed the files in user1's directory. After installing sqlalchemy in user2's directory the problem went away.

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

    try this:

    from flask.ext.sqlalchemy import SQLAlchemy
    
    0 讨论(0)
  • 2020-12-08 04:19

    I just experienced the same problem. Apparently, there is a new distribution method, the extension code is no longer stored under flaskext.

    Source: Flask CHANGELOG This worked for me:

    from flask_sqlalchemy import SQLAlchemy
    
    0 讨论(0)
  • 2020-12-08 04:21

    This code works perfectly:

    import sqlalchemy
    

    Maybe you installed the package in another version of the interpreter?

    Also, like Shawley pointed out, you need to have the flask extension installed in order for it to be accessible.

    0 讨论(0)
提交回复
热议问题