Mercurial fails with import error on Mac OS X

If you installed Mercurial, but it fails with the following error message when you try to use it:

Traceback (most recent call last):
  File "/usr/local/bin/hg", line 38, in <module>
  File "/Library/Python/2.7/site-packages/mercurial/", line 28, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/Library/Python/2.7/site-packages/mercurial/", line 41, in dispatch
    req.ui = uimod.ui()
  File "/Library/Python/2.7/site-packages/mercurial/", line 45, in __init__
    for f in scmutil.rcpath():
  File "/Library/Python/2.7/site-packages/mercurial/", line 464, in rcpath
    _rcpath = osrcpath()
  File "/Library/Python/2.7/site-packages/mercurial/", line 436, in osrcpath
    path = systemrcpath()
  File "/Library/Python/2.7/site-packages/mercurial/", line 489, in systemrcpath
    path.extend(rcfiles(os.path.join(p, root)))
  File "/Library/Python/2.7/site-packages/mercurial/", line 474, in rcfiles
    for f, kind in osutil.listdir(rcdir)
  File "/Library/Python/2.7/site-packages/mercurial/", line 86, in __getattribute__
  File "/Library/Python/2.7/site-packages/mercurial/", line 58, in _load
    mod = _origimport(head, globals, locals)
ImportError: dlopen(/Library/Python/2.7/site-packages/mercurial/, 2): no suitable image found.  Did find:
    /Library/Python/2.7/site-packages/mercurial/ mach-o, but wrong architecture

Then your Python most likely runs in 32-bit mode. To force Python to run in 64-bit mode, run this command:

defaults write Prefer-32-Bit -bool no