I am getting this error while importing nsprefixes from docx library.
from docx import nsprefixes
Any idea on How to resolve this issue?
nsprefixes
is an object from the obsolete, much prior version of python-docx
here:
https://github.com/mikemaccana/python-docx
If you want to use that code you'll need to uninstall the current package and install the very old one:
$ pip uninstall python-docx
$ pip install docx
Doing so is not generally recommended, but since you haven't mentioned anything about your use case I'll leave that decision to you.
That code base was completely re-written to create the current version, so the two are not compatible in any way.
There is a generally similar object in the new version under the name nsmap
:
from docx.oxml.ns import nsmap
Which you can inspect here:
https://github.com/python-openxml/python-docx/blob/master/docx/oxml/ns.py