ImportError: No module named sqlalchemy

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

    Did you install flask-sqlalchemy? It looks like you have SQLAlchemy installed but not the Flask extension. Try pip install Flask-SQLAlchemy in your project's virtualenv to install it from PyPI.

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

    So here is an idea!

    Since it seemed to work somewhere else.

    install python-virtualenv and optionally you can install virtualenv-wrapper (which is pretty cool to create projects and so on)

    In each env, you might have different versions of eggs. In other word, you could have sqlalchemy 1 and sqlaclhemy 1.5 in two different envs and they won't conflict with each others. It seems that you have a problem with your currently installed eggs.

    So here we go:

    virtualenv --no-site-packages foo
    source foo/bin/activate
    

    The parameter --no-site-packages will create a virtualenv and not use the packages already installed on your computer. It's pretty much like a bare python install.

    source foo/bin/activate loads the virtualenv.

    It's not that really userfriendly. And that's why http://www.doughellmann.com/projects/virtualenvwrapper/ exists.

    That said, you should see somthing like thant in your terminal "(foo)user@domain$:" once your virtualenv is activated. It means that you can go on!

    Then you have to do.

    python setup.py develop of your project. It should download and install dependencies of your project in the virtualenv located in foo. If you need to install anything else, please use pip or easy_install without using sudo. When using virtualenv, you almost never need to use sudo. Sudo will install package in your global python install while it's not required and not really desirable.

    If something happens in your virtualenv, you can always delete it and create a new one. This is no big deal. No need to mess with anything. Doesn't work? start over, do pip install -U if needed, define the versions if needed and so on.

    Last but not least, in the other answers, it seems that the import changed. If the new versions for flask-sqlalchemy is located somewhere else, you should update your import or install the version you used to use.

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