win7 64, python3.5
When i type 'from docx import Document', it shows error.
Traceback (most recent call last):
File "
File "C:\Python35\lib\site-packages\docx.py", line 30, in
from exceptions import PendingDeprecationWarning
ImportError: No module named 'exceptions'
What can I do?
Looks like you installed docx rather than python-docx. docx is the (early) legacy version of python-docx.
So I should use python-docx instead of using pip?
$ pip uninstall docx
$ pip install python-docx
@scanny I followed this but did not help. Any idea?
C:\Users\x>pip uninstall docx
Cannot uninstall requirement docx, not installed
C:\Users\x>pip install python-docx
Requirement already satisfied: python-docx in c:\python36\lib\site-packages
Requirement already satisfied: lxml>=2.3.2 in c:\python36\lib\site-packages (from python-docx)
C:\Users\x>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
from docx import Document
Traceback (most recent call last):
File "", line 1, in
File "C:\Python36\lib\site-packagesdocx__init__.py", line 3, in
from docx.api import Document # noqa
File "C:\Python36\lib\site-packagesdocxapi.py", line 14, in
from docx.package import Package
File "C:\Python36\lib\site-packagesdocx\package.py", line 11, in
from docx.opc.package import OpcPackage
File "C:\Python36\lib\site-packagesdocx\opc\package.py", line 12, in
from .part import PartFactory
File "C:\Python36\lib\site-packagesdocx\opc\part.py", line 12, in
from .oxml import serialize_part_xml
File "C:\Python36\lib\site-packagesdocx\opc\oxml.py", line 12, in
from lxml import etree
ImportError: DLL load failed: The specified procedure could not be found.
`
@scanny,
solved. Trick was in uninstalling lxml
pip uninstall lxml
Download lxml binary from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
Installed whl from binary
pip install lxml-3.8.0-cp36-cp36m-win32.whl
Most helpful comment
Looks like you installed
docxrather thanpython-docx.docxis the (early) legacy version ofpython-docx.