ImportError: No module named roman
Post by
on June 7, 2012reStructuredText is the best word processing application on the planet. However, it can be frustrating to work with when it doesn't work properly.
I am using a Macbook Pro with Snow Leopard and received an error that the roman module isn't present, as shown here:
$ rst2pdf file.rst Traceback (most recent call last): File "/usr/local/bin/rst2pdf", line 8, in <module> load_entry_point('rst2pdf==0.17.dev-r0', 'console_scripts', 'rst2pdf')() File "/Library/Python/2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 277, in load_entry_point def get_entry_info(dist, group, name): File "/Library/Python/2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 2180, in load_entry_point except AttributeError: File "/Library/Python/2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 1913, in load return entry File "/Library/Python/2.6/site-packages/rst2pdf-0.17.dev_r0-py2.6.egg/rst2pdf/createpdf.py", line 63, in <module> from docutils.parsers.rst import directives File "/Library/Python/2.6/site-packages/docutils/parsers/rst/__init__.py", line 75, in <module> from docutils.parsers.rst import states File "/Library/Python/2.6/site-packages/docutils/parsers/rst/states.py", line 108, in <module> import roman ImportError: No module named roman
To resolve this issue, do the following:
1. Download the roman.py module.
$ wget http://svn.python.org/projects/python/branches/pep-0384/Doc/tools/roman.py
2. Put the module in a directory visible to Python.
You have two options to accomplish this:
a. Put the module in the Python site-packages folder.
To find the site-packages folder, first find what python version you are using:
$ python -V Python 2.6.1
Next, find the correct site-packages folder. In most unix environments you will use the folder located at "/usr/lib/python2.6/site-
$ sudo find / -name "site-packages" | grep "Python" /Library/Python/2.3/site-packages /Library/Python/2.5/site-packages /Library/Python/2.6/site-packages
Then, simply copy the module to the folder, making sure you choose the folder according to the version you are using:
$ sudo cp roman.py /Library/Python/2.6/site-packages/
Note: You can either copy the one in your working directory and delete it, or simply move it with 'mv'.
b. Put the module in a folder of your choosing and add the folder to the PYTHONPATH.
The second option is to create a folder and place the module (the python.py file) in it and then update your PYTHONPATH to include that folder like so:
$ export PYTHONPATH=/path/to/folder
Now, the error should no longer occur. However, to make this change permanent you will want to add the above line to your bashrc (or profile for Mac OS X) file.
Note: the bashrc or profile can be found at ~/.bashrc and ~/.profile respectively. Simply add the 'export PYTHONPATH=/path/to/folder' line to it.