diff --git a/contrib/genosxversion.py b/contrib/genosxversion.py
index fc8299319ffe3f462fbaeefae3ba740b913c20eb_Y29udHJpYi9nZW5vc3h2ZXJzaW9uLnB5..148d177a4f2dc4b75aab772a90583718253d3e7c_Y29udHJpYi9nZW5vc3h2ZXJzaW9uLnB5 100755
--- a/contrib/genosxversion.py
+++ b/contrib/genosxversion.py
@@ -6,9 +6,14 @@
 import subprocess
 import sys
 
-# Always load hg libraries from the hg we can find on $PATH.
-hglib = subprocess.check_output(['hg', 'debuginstall', '-T', '{hgmodules}'])
-sys.path.insert(0, os.path.dirname(hglib))
+try:
+    # Always load hg libraries from the hg we can find on $PATH.
+    hglib = subprocess.check_output(['hg', 'debuginstall', '-T', '{hgmodules}'])
+    sys.path.insert(0, os.path.dirname(hglib))
+except subprocess.CalledProcessError:
+    # We're probably running with a PyOxidized Mercurial, so just
+    # proceed and hope it works out okay.
+    pass
 
 from mercurial import util