ImportError: No module named flask_mail

余生长醉 提交于 2020-07-08 00:43:52

问题


from flask_mail import Mail,Message
from flask import Flask

I am trying to mail but import error is occurring


回答1:


The are two packages by that name:

  • The project found on GitHub and in PyPI uses flask_mail as the package name; see their documentation and project source code.

    Their layout indeed requires:

    from flask_mail import Mail, Message
    

    This is a fork of the other project, but is currently actively maintained.

  • There is a project on Bitbucket, and their Flask-Mail documentation and the project source code show that the correct import is:

    from flaskext.mail import Mail, Message
    

    This project appears to be outdated and has not seen an update for almost 3 years now. The Github project names the same original author, it appears to be an updated fork. I'd stick with the Github project.

If neither works, then there is no such module installed, not in the location that the Python version running your Flask server can find.




回答2:


You have to install flask_mail in order to be able to import it. if you are working with linux type this into your terminal and hit enter: $ sudo pip install flask_mail



来源:https://stackoverflow.com/questions/24585913/importerror-no-module-named-flask-mail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!