Modulenotfounderror: no module named docx (Solution)

Modulenotfounderror_ no module named docx (Solution)

Modulenotfounderror: no module named docx error occurs if python-docx is either not properly installed or its path is misconfigured. In this article we will explore the best ways to fix this error. Python-docx library helps in automating Microsoft docx. Mostly when we want to use Microsoft Docx as reporting layer. We can automate the reports, extract, etc using python with the library in single click. But before starting this doc automation, we need to fix this ModuleNotFoundError. So lets start.

 

Modulenotfounderror: no module named docx ( Solution ) –

Firstly we will use pip as package manager to install this python-docx package.

Solution 1 : Using pip for python-docx installation –

Use the below command to install python-docx  latest version available in PyPI Hub.

pip install python-docx

Currently the latest version is 0.8.11.

If you are getting permission issue then if you are a linux user then please add sudo keyword along with the above command for admin permission. For Windows user, you need to open command prompt in admin mode ( right click and select ).

If you want to install any specific version for python-docx then you can specify in the above command like below.

pip install python-docx==0.8.10

The version you can change as per the code compatibility. For Version related information read the release notes.

Modulenotfounderror no module named docx solved by installation using pip
Modulenotfounderror no module named docx solved by installation using pip

Solution 2 : Using conda for python-docx installation –

Some developer prefer conda to install any package in python. Mostly who love to work on anaconda distribution prefer to install packages with conda package manager. It is similar to pip only. I mean it also install python package in single command. Here is the command required to install python-docx module with conda.

conda install -c conda-forge python-docx

Modulenotfounderror no module named docx solved by installation using conda
Modulenotfounderror no module named docx solved by installation using conda

Solution 3 : Using Source code for python-docx installation –

If you want to install the python-docx using source code then do the following steps.

Step 1: Download the source code ( we can use wget command ) from the git repo for python-docx.

Step 2: change the directory to the python-docx

Step 3: execute the command

python setup.py install

docx installation using source code
docx installation using source code

Thanks 

Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Meet Abhishek ( Chief Editor) , a data scientist with major expertise in NLP and Text Analytics. He has worked on various projects involving text data and have been able to achieve great results. He is currently manages Datasciencelearner.com, where he and his team share knowledge and help others learn more about data science.
 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner