python docx installed but cannot be imported

3.7k views Asked by At

Hi I'm using windows and installing python-docx using pip. I went into C:\Python27\Scripts and ran pip install python-docx . I thought it should have been installed.

But when i run a simple import

from docx import Documents

it ran into an "ImportError: No module named docx" when i checked the modules installed using pip using pip list python-docx 0.8.7 is installed. Does anyone know why whis is happening?

Update : I just found out the script runs when i run the script on windows command line, but it doesn't run on IDLE could it be some configurations on IDLE?

2

There are 2 answers

5
smitty_werbenjagermanjensen On

It is not Documents just Document

It should just be:

from docx import Document

Also here is an example from the documentation:

Documentation for command

0
Black Mask On

Just in case if someone is still having problem, please update your setuptools and install python-docx.

pip install -U setuptools

pip install --pre python-docx