Search code examples
python-3.xdocx-mailmerge

ImportError: cannot import name 'MailMerge' from 'mailmerge'


I am having this problem whereby I can not copy

from __future__ import print_function
from mailmerge import MailMerge
from datetime import date

I am getting

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-6791e9480127> in <module>
      1 from __future__ import print_function
----> 2 from mailmerge import MailMerge
      3 from datetime import date

ImportError: cannot import name 'MailMerge' from 'mailmerge' (C:\Users\username\AppData\Roaming\Python\Python37\site-packages\mailmerge\__init__.py)

Solution

  • Jupyter Notebook

    1. Open Anaconda Prompt and press 'conda install lxml'

    2. You should get that "The following packages will be UPDATED:" press 'y'

    3. In your jupyter notebook write !pip install docx-mailmerge

    4. Then you can simply write this:

      from future import print_function

      from mailmerge import MailMerge

      from datetime import date

    5. That is all, it should work

    I learned this from this webpage

    This had solved my problem.