Search code examples
flaskimporterrorflask-mail

ImportError: No module named flask_mail


from flask_mail import Mail,Message
from flask import Flask

I am trying to mail but import error is occurring


Solution

  • 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.