[Solved] When import docx in python3.3 I have error ImportError: No module named ‘exceptions’

when I import docx I have this error:

>File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/docx-0.2.4-py3.3.egg/", line 30, in <module>
        from exceptions import PendingDeprecationWarning
    ImportError: No module named 'exceptions'

How to fix this error (python3.3, docx 0.2.4)?

Solution #1:

If you are using python 3x don’t do pip install docx instead go for

pip install python-docx 

It is compatible with python 3.x

Official Documentation available here:

Respondent: Arun

Solution #2:

  1. Uninstall docx module with pip uninstall docx
  2. Download python_docx-0.8.6-py2.py3-none-any.whl file from
  3. Run pip install python_docx-0.8.6-py2.py3-none-any.whl to reinstall docx.
    This solved the above import error smoothly for me. Just to provide a solution…
Respondent: Vancent

Solution #3:

When want to use import docx, be sure to install python-docx, not docx.You can install the module by running pip install python-docx.

The installation name docx is for a different module

when you are going to import the python-docx module,
you’ll need to run
import docx, not import python-docx.

if still you want to use docx module then:

First of all, you will need to make sure that the docx module is installed.
If not then simply run pip install docx.
If it shows ‘*requirement already satisfied*’
then the solution is :

  1. Go to the library to find file,
    you’ll need to go to directory where you installed python then Libsite-packages and find file
  2. Open file in text editor and find this code

    from exceptions import PendingDeprecationWarning
  3. Replace the above code with
    from exceptions import PendingDeprecationWarning
except ImportError:
  1. Save the file
  2. Now you can run import docx module in Python 3.x without any problem
Respondent: Sameer Khan

Solution #4:

If you’re using python 3.x, Make sure you have both python-docx & docx installed.

Installing python-docx :

pip install python-docx

Installing docx :

pip install docx
Respondent: Kalpit

Solution #5:

In Python 3 exceptions module was removed and all standard exceptions were moved to builtin module. Thus meaning that there is no more need to do explicit import of any standard exceptions.

copied from

Respondent: sajid

Solution #6:

You may be install docx, not python-docx

You can see this for install python-docx

Respondent: ???

Solution #7:

The problem, as was noted previously in comments, is the docx module was not compatible with Python 3. It was fixed in this pull-request on github:

Since the exception is now built-in, the solution is to not import it.
@@ -27,7 +27,12 @@
 except ImportError:
     TAGS = {}

-from exceptions import PendingDeprecationWarning
+# Handle PendingDeprecationWarning causing an ImportError if using Python 3
+    from exceptions import PendingDeprecationWarning
+except ImportError:
+    pass
 from warnings import warn

 import logging
Respondent: Dmitry

Solution #8:

You need to make it work with python3.

                     sudo pip3 install python-docx

This installation worked for me in Python3 without any further additions.

             >> import docx

PS: Note that the ‘pip install python-docx’ or apt-get python3-docx are not useful.

Respondent: Shagun

Solution #9:

I had the same problem, but pip install python-docx worked for me, I’m using python 3.7.1

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy