I tried import Document function from docx after installation but it throws import error.
when i import docx alone it works.
"from docx import Document" throws error.
docx version - 0.2.4
Python 2.7.3

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
Yes thanks Scanny, that is what i did exactly and solved it yesterday.
Hello, i had the same problem ImportError: cannot import name Document
My problem was in my file name: docx.py :D
Changed it and deleted __pycache__ directory and docx.pyc from my folder and now all is ok!
I am having the same Import error.
I didn't have docx or python-docx earlier.
I tried both of them (leaving the other uninstalled), but I am still getting the error.
@hitzkrieg - Me too
I think it is from corenlp_xml.document import Document
On 08-Jun-2017 1:39 PM, "Anshaj Goel" notifications@github.com wrote:
@hitzkrieg https://github.com/hitzkrieg - Me too
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/python-openxml/python-docx/issues/41#issuecomment-307066681,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMdexiB1yCJ8WUmTKAGA-5Vj58C_SBZtks5sB89ggaJpZM4B2Xma
.
@scanny Thank you, I did exactly as you suggested and it solved the problem.
Uninstalled docx and installed python-docx.

@scanny I am still getting error..please help
I am getting the following error while installing python-docx
pip install python-docx
Using cached https://files.pythonhosted.org/packages/e4/83/c66a1934ed5ed8ab1dbb9931f1779079f8bca0f6bbc5793c06c4b5e7d671/python-docx-0.8.10.tar.gz
Requirement already satisfied: lxml>=2.3.2 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from python-docx)
Installing collected packages: python-docx
Running setup.py install for python-docx ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/var/folders/0c/v_yb4q7n2h3fg94rlfrr165r0000gn/T/pip-build-fDOKCT/python-docx/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/0c/v_yb4q7n2h3fg94rlfrr165r0000gn/T/pip-_QsXvN-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/docx
copying docx/package.py -> build/lib/docx
copying docx/compat.py -> build/lib/docx
copying docx/blkcntnr.py -> build/lib/docx
copying docx/__init__.py -> build/lib/docx
copying docx/section.py -> build/lib/docx
copying docx/shared.py -> build/lib/docx
copying docx/api.py -> build/lib/docx
copying docx/document.py -> build/lib/docx
copying docx/settings.py -> build/lib/docx
copying docx/exceptions.py -> build/lib/docx
copying docx/shape.py -> build/lib/docx
copying docx/table.py -> build/lib/docx
creating build/lib/docx/oxml
copying docx/oxml/coreprops.py -> build/lib/docx/oxml
copying docx/oxml/simpletypes.py -> build/lib/docx/oxml
copying docx/oxml/__init__.py -> build/lib/docx/oxml
copying docx/oxml/ns.py -> build/lib/docx/oxml
copying docx/oxml/section.py -> build/lib/docx/oxml
copying docx/oxml/shared.py -> build/lib/docx/oxml
copying docx/oxml/numbering.py -> build/lib/docx/oxml
copying docx/oxml/document.py -> build/lib/docx/oxml
copying docx/oxml/styles.py -> build/lib/docx/oxml
copying docx/oxml/settings.py -> build/lib/docx/oxml
copying docx/oxml/exceptions.py -> build/lib/docx/oxml
copying docx/oxml/shape.py -> build/lib/docx/oxml
copying docx/oxml/table.py -> build/lib/docx/oxml
copying docx/oxml/xmlchemy.py -> build/lib/docx/oxml
creating build/lib/docx/opc
copying docx/opc/package.py -> build/lib/docx/opc
copying docx/opc/coreprops.py -> build/lib/docx/opc
copying docx/opc/compat.py -> build/lib/docx/opc
copying docx/opc/oxml.py -> build/lib/docx/opc
copying docx/opc/constants.py -> build/lib/docx/opc
copying docx/opc/__init__.py -> build/lib/docx/opc
copying docx/opc/spec.py -> build/lib/docx/opc
copying docx/opc/shared.py -> build/lib/docx/opc
copying docx/opc/packuri.py -> build/lib/docx/opc
copying docx/opc/phys_pkg.py -> build/lib/docx/opc
copying docx/opc/exceptions.py -> build/lib/docx/opc
copying docx/opc/pkgreader.py -> build/lib/docx/opc
copying docx/opc/part.py -> build/lib/docx/opc
copying docx/opc/rel.py -> build/lib/docx/opc
copying docx/opc/pkgwriter.py -> build/lib/docx/opc
creating build/lib/docx/dml
copying docx/dml/color.py -> build/lib/docx/dml
copying docx/dml/__init__.py -> build/lib/docx/dml
creating build/lib/docx/enum
copying docx/enum/style.py -> build/lib/docx/enum
copying docx/enum/__init__.py -> build/lib/docx/enum
copying docx/enum/section.py -> build/lib/docx/enum
copying docx/enum/text.py -> build/lib/docx/enum
copying docx/enum/shape.py -> build/lib/docx/enum
copying docx/enum/table.py -> build/lib/docx/enum
copying docx/enum/dml.py -> build/lib/docx/enum
copying docx/enum/base.py -> build/lib/docx/enum
creating build/lib/docx/image
copying docx/image/tiff.py -> build/lib/docx/image
copying docx/image/gif.py -> build/lib/docx/image
copying docx/image/constants.py -> build/lib/docx/image
copying docx/image/jpeg.py -> build/lib/docx/image
copying docx/image/__init__.py -> build/lib/docx/image
copying docx/image/png.py -> build/lib/docx/image
copying docx/image/bmp.py -> build/lib/docx/image
copying docx/image/exceptions.py -> build/lib/docx/image
copying docx/image/helpers.py -> build/lib/docx/image
copying docx/image/image.py -> build/lib/docx/image
creating build/lib/docx/styles
copying docx/styles/style.py -> build/lib/docx/styles
copying docx/styles/latent.py -> build/lib/docx/styles
copying docx/styles/__init__.py -> build/lib/docx/styles
copying docx/styles/styles.py -> build/lib/docx/styles
creating build/lib/docx/parts
copying docx/parts/story.py -> build/lib/docx/parts
copying docx/parts/__init__.py -> build/lib/docx/parts
copying docx/parts/numbering.py -> build/lib/docx/parts
copying docx/parts/hdrftr.py -> build/lib/docx/parts
copying docx/parts/document.py -> build/lib/docx/parts
copying docx/parts/styles.py -> build/lib/docx/parts
copying docx/parts/settings.py -> build/lib/docx/parts
copying docx/parts/image.py -> build/lib/docx/parts
creating build/lib/docx/text
copying docx/text/run.py -> build/lib/docx/text
copying docx/text/__init__.py -> build/lib/docx/text
copying docx/text/font.py -> build/lib/docx/text
copying docx/text/tabstops.py -> build/lib/docx/text
copying docx/text/parfmt.py -> build/lib/docx/text
copying docx/text/paragraph.py -> build/lib/docx/text
creating build/lib/docx/oxml/text
copying docx/oxml/text/run.py -> build/lib/docx/oxml/text
copying docx/oxml/text/__init__.py -> build/lib/docx/oxml/text
copying docx/oxml/text/font.py -> build/lib/docx/oxml/text
copying docx/oxml/text/parfmt.py -> build/lib/docx/oxml/text
copying docx/oxml/text/paragraph.py -> build/lib/docx/oxml/text
creating build/lib/docx/opc/parts
copying docx/opc/parts/coreprops.py -> build/lib/docx/opc/parts
copying docx/opc/parts/__init__.py -> build/lib/docx/opc/parts
creating build/lib/docx/templates
copying docx/templates/default-header.xml -> build/lib/docx/templates
copying docx/templates/default-settings.xml -> build/lib/docx/templates
copying docx/templates/default-footer.xml -> build/lib/docx/templates
error: can't copy 'docx/templates/default-docx-template': doesn't exist or not a regular file
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/var/folders/0c/v_yb4q7n2h3fg94rlfrr165r0000gn/T/pip-build-fDOKCT/python-docx/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/0c/v_yb4q7n2h3fg94rlfrr165r0000gn/T/pip-_QsXvN-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/0c/v_yb4q7n2h3fg94rlfrr165r0000gn/T/pip-build-fDOKCT/python-docx/
@addyag93 Please don't post to closed issues. See #594 for solution to this problem.
I don't know what is problem for you but for me same problem because stupid reason that I create a file docx.py with in same directory than all other program getting this error.
For whoever might find this on search, this error is raised when trying to use the
python-docxv0.3.0+ API ondocxv0.2.x or prior versions.The solution, assuming you want to use the newer version, is to uninstall the
docxpackage and installpython-pptx, perhaps something like this:$ pip uninstall docx $ pip install python-docx
I'm working through the "Automate the Boring Stuff" text from No Starch and was completely stuck. Thanks!
Same exact situation happened to me. Wasted an entire afternoon. Thanks for posting the solution.
You cannot have "docx" in the name of your .py file.
On Fri, Sep 25, 2020 at 6:09 AM isailaandrei notifications@github.com
wrote:
Hey, I have the same error, but I've installed the python-docx (see
screenshot). Not sure what to try.[image: image]
https://user-images.githubusercontent.com/6235707/94255046-53f06d00-ff30-11ea-8d8b-6db7cdcc1556.png—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/python-openxml/python-docx/issues/41#issuecomment-698845900,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/APCINBQZAKT5ZT7ELVKM3RTSHRT7FANCNFSM4AOZPGNA
.
--
Mark Kiehl
Most helpful comment
For whoever might find this on search, this error is raised when trying to use the
python-docxv0.3.0+ API ondocxv0.2.x or prior versions.The solution, assuming you want to use the newer version, is to uninstall the
docxpackage and installpython-pptx, perhaps something like this: