Search code examples
pythonms-worddocxpython-docx

How to install Python docx module on mac osx


I'm trying to generate .docx files using Python. I searched the web and posts here and found a module:

https://github.com/mikemaccana/python-docx/blob/master/README.markdown

It says to install using easy_install or pip, which I have no idea how to do. I went to python website to install pip from the instructions given on python documentation:

http://guide.python-distribute.org/installation.html

So I downloaded and followed directions:

$ tar xzf pip-0.7.2.tar.gz
$ cd pip-0.7.2
$ python setup.py install

But when I do python setup.py install, I get error message:

Johns-MacBook-Pro:pip-0.7.2 John$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 2, in <module>
from setuptools import setup

ImportError: No module named setuptools

Can someone please help me install step by step for a newb? Thanks in advance for all of your help!


Solution

  • Pip can install straight from the git repository

    You just have to tell him to use git and give him the URL of the git rep

    pip install git+git://github.com/mikemaccana/python-docx.git
    

    You will also need to install lxml (as written in the setup.py) and PIL (as you will discover when you try to import the module).

    pip install PIL
    pip install lxml
    pip install python-dateutil