4

I've installed docutils on my Mac OS system following the docutils instructions.

I've also done:

$ sudo cp tools/buildhtml.py tools/rst2html.py /usr/local/bin

However, if I open a command line and type rst2html, I get 'command not found'.

If I type rst2html.py, there's no problem, so the Python file itself is on my path.

How do I get my system to recognize rst2html as a valid command?

Thanks!

2 Answers 2

4

I don't know about mac, but generally in a Unix system the file extension isn't implied. Indeed a file name extension rarely has any special meaning at all. However there are lot of Unix tricks to help you, perhaps creating a symbolic link:

$ sudo ln -s rst2html.py /usr/local/bin/rst2html
0
2

When you type the command rst2html on the command line, it's going to look for a program called rst2html (not rst2html.somethingorother) in the directories in your PATH. If you want rst2html to work, you need a file named rst2html. There are several ways to do this:

  1. Rename the program. There's no actual need for the .py extension, as the system knows it's a Python script because of its shebang line.

    sudo mv /usr/local/bin/rst2html.py /usr/local/bin/rst2html
    
  2. Hard-link the program. You can have the program listed in /usr/local/bin under two different names, rst2html.py and rst2html, and either one can be used to launch it.

    sudo ln /usr/local/bin/rst2html.py /usr/local/bin/rst2html
    
  3. Symbolic-link the program. Similar to hard-linking, except that only one is the "real" file, the other is just a unix-style alias. This may be a bit easier to manage than hard-linking, because if you ever install an updated version, the link will automatically use the new version (while with a hard link, you'd need to update the link manually).

    sudo ln -s rst2html.py /usr/local/bin/rst2html
    

Personally, I'd just rename it (option 1), but either of the other options should work fine as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .