I'm using Ubuntu 10.04 and I just installed Mercurial 1.5.4 from source (see this question for some installation trouble that I had). Now, however, when I invoke:


I get the following:

  File "/usr/local/bin/hg", line 27, in <module>
  File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 47, in _load
    mod = _origimport(head, globals, locals)
ImportError: No module named osutil


find /usr/local/lib -name osutil* -print



which I assume can be loaded by Python scripts similar to Perl and XS. With the exception of adding python-dev (see answer at above link) my Python installation is exactly as it came with Ubuntu 10.04 after upgrading to 10.04 from 9.10.

What's going on?

  • from your earlier question, it seems the C modules are still not properly compiled. They should be with your manual install in /usr/lib/pymodules/python2.6/mercurial/.
    – tonfa
    Jun 26 '10 at 11:48
  • Ok, so what do I do about it?
    – gvkv
    Jun 26 '10 at 13:13

This usually means you need to uninstall the mercurial-common package from Ubuntu - it can be earlier in the Python search path and cause weird problems like this.

  • This did it for me. I had a manual compiled Mercurial and remove the Ubuntu version first but had that package still around. Sep 30 '11 at 12:49

Per http://mercurial.808500.n3.nabble.com/Mercurial-1-5-2-released-td806821.html, you need the python-dev package. For example, on Debian or Ubuntu, you would install it with

sudo apt-get install python-dev

If that doesn't work right away, then re-do the Mercurial source installation, and that may solve the problem (it did for me).


if you are running under windows you will find a folder "pure" inside of "\site-packages\mercurial\". Inside of it, there are a bunch of .py (osutil.py is one of them)

Just copy all files inside "pure" to the "mercurial" folder and DONE! It just starts working.

Hope this helps!

  • This gave me 'ImportError: .py version of mercurial.osutil found where C version should exist.'
    – Noumenon
    Feb 8 '16 at 23:48

Just for the sake of helping others, I just solved the missing osutil.py in Ubuntu 13.04, without which mercurial won't run.

I had to install python-sphinx (and related). This looks like a dependency check failure in the mercurial package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.