Python docx module ModuleNotFoundError
Question:
I am a windows 7 user with MS-Office 2016 and python 3.6.
I recently found out that you can write word documents with python.
I looked on how to do that
I installed the docx module:
pip install docx
But whenever i try to import the docx module i get this error:
>>> from docx import Document
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:UsersHuzefaAppDataLocalProgramsPy
in <module>
from exceptions import PendingDeprecationWarn
ModuleNotFoundError: No module named 'exceptions'
I have even tried this but it wont work:
pip install exceptions
I get this error:
ERROR: Could not find a version that satisfies the requirement exceptions (from versions: none)
ERROR: No matching distribution found for exceptions
I thought that maybe this is happening because docx is a python-2 module but it is not. I found it out here
so can someone tell me what i am doing wrong?
Answers:
I suggest that you can try like this –
$ pip install --pre python-docx
Or you can also try sudo command –
$ sudo pip install --pre python-docx
After that try –
from docx import Document
From here you can find [https://python-docx.readthedocs.io/en/latest/user/install.html][1]
try using:
pip install python-docx
It worked for me!
The problem here is that the name for installation and usage are different:
- To install:
pip install python-docx
- To use:
from docx import Document
Install with the correct name (i.e. python-docx
) and it shall work.
I am a windows 7 user with MS-Office 2016 and python 3.6.
I recently found out that you can write word documents with python.
I looked on how to do that
I installed the docx module:
pip install docx
But whenever i try to import the docx module i get this error:
>>> from docx import Document
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:UsersHuzefaAppDataLocalProgramsPy
in <module>
from exceptions import PendingDeprecationWarn
ModuleNotFoundError: No module named 'exceptions'
I have even tried this but it wont work:
pip install exceptions
I get this error:
ERROR: Could not find a version that satisfies the requirement exceptions (from versions: none)
ERROR: No matching distribution found for exceptions
I thought that maybe this is happening because docx is a python-2 module but it is not. I found it out here
so can someone tell me what i am doing wrong?
I suggest that you can try like this –
$ pip install --pre python-docx
Or you can also try sudo command –
$ sudo pip install --pre python-docx
After that try –
from docx import Document
From here you can find [https://python-docx.readthedocs.io/en/latest/user/install.html][1]
try using:
pip install python-docx
It worked for me!
The problem here is that the name for installation and usage are different:
- To install:
pip install python-docx
- To use:
from docx import Document
Install with the correct name (i.e. python-docx
) and it shall work.