Bouke / docx-mailmerge

Mail merge for Office Open XML (docx) files without the need for Microsoft Office Word.
MIT License
273 stars 104 forks source link

from mailmerge import MailMerge gives an error. #58

Closed petey8 closed 5 years ago

petey8 commented 6 years ago

I have the latest version of python installed on my macOS and installed the latest docx-mailmerge via the terminal but keep getting this error when trying to import it in my python shell:

from mailmerge import MailMerge Traceback (most recent call last): File "<pyshell#38>", line 1, in from mailmerge import MailMerge ImportError: cannot import name 'MailMerge' from 'mailmerge' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mailmerge/init.py)

I think this is an easy to fix error, but I can't figure out what the problem is.. I'm new to python so any advice would be appreciated!!

Thanks!

moriartynz commented 6 years ago

I had this problem. It was that I called my project Mailmerge and my pyfile mailmerge.py Once I renamed those, the problem was solved. Doh!

ghost commented 6 years ago

I had this problem and I found two possible solutions:

  1. As user scanny mentioned:

_For whoever might find this on search, this error is raised when trying to use the python-docx v0.3.0+ API on docx v0.2.x or prior versions.

The solution, assuming you want to use the newer version, is to uninstall the docx package and install python-pptx, perhaps something like this:

$ pip uninstall docx $ pip install python-docx_

  1. And probably similar issue (that worked for me): $ pip uninstall mailmerge $ pip install docx-mailmerge

Hope it helps

WeidnersApps commented 5 years ago

Nothing works for me, is there any other solution?

KirtiDahiya commented 5 years ago

Hi WeidnersApps, Did you find the solution?

joaoe commented 5 years ago

This bit me because I ran pip install mailmerge instead of pip install docx-mailmerge. Make sure you have the correct package installed.

brenodiogo commented 5 years ago

worked for me.

pip uninstall mailmerge pip install docx-mailmerge

then run your script:

python script.py

lodebosmans commented 5 years ago

Nothing works for me as well.. I'm using PyCharm to run the code.

Traceback (most recent call last): File "C:/Users/Lode/PycharmProjects/WestFitMutualiteit/WestFitMutualiteit.py", line 2, in from mailmerge import MailMerge ModuleNotFoundError: No module named 'mailmerge'

brenodiogo commented 5 years ago

sounds like an environment issue. make sure PyCharm is using the correct python interpreter.

import sys print(sys.version)

for path in sys.path: print(path)

this should print a list of directories where Python searches for modules.

if you navigate these directories, you should be able to find mailmerge there. if PyCharm is using the wrong python interpreter, you need to point it to the correct one

lodebosmans commented 5 years ago

sounds like an environment issue. make sure PyCharm is using the correct python interpreter.

import sys print(sys.version)

for path in sys.path: print(path)

this should print a list of directories where Python searches for modules.

if you navigate these directories, you should be able to find mailmerge there. if PyCharm is using the wrong python interpreter, you need to point it to the correct one

Seems like you are right. Had to do some more configuring of PyCharm. Works perfectly now. Thanks for the support!

joaoe commented 5 years ago

So, this is not an issue with mailmerge, and can be closed.

mattborhan commented 5 years ago

Hi Bouke and Joaoe,

I don't think it's an environment issue. I'm using Jupyter on Azure notebooks. I get the same error and none of the suggested solutions worked by far. I appreciate if you reopen the post so we can benefit from other people's recommendations.

Thanks, M

danerlt commented 4 years ago

I had this problem and I found two possible solutions:

  1. As user scanny mentioned:

For whoever might find this on search, this error is raised when trying to use the python-docx v0.3.0+ API on docx v0.2.x or prior versions. The solution, assuming you want to use the newer version, is to uninstall the docx package and install python-pptx, perhaps something like this: $ pip uninstall docx $ pip install python-docx

  1. And probably similar issue (that worked for me): $ pip uninstall mailmerge $ pip install docx-mailmerge

Hope it helps

Thanks