Problems with Mercurial

It's been a while since I had this problem with mercurial in Archlinux, and now was time to fix it.

Before I started using virtualenv months ago, I did all my experiments in the Archlinux root for Python2.7, it seems it(or I) broke something
in a compilation and it affected Mercurial build for my system. I couldn't even clone a mercurial repository, it always threw this interesting

    Traceback (most recent call last):
  File "/usr/bin/hg", line 36, in <module>
  File "/usr/lib/python2.7/site-packages/mercurial/", line 86, in __getattribute__
  File "/usr/lib/python2.7/site-packages/mercurial/", line 58, in _load
    mod = _origimport(head, globals, locals)
  File "/usr/lib/python2.7/site-packages/mercurial/", line 202, in <module>
  File "/usr/lib/python2.7/site-packages/mercurial/", line 86, in __getattribute__
  File "/usr/lib/python2.7/site-packages/mercurial/", line 58, in _load
    mod = _origimport(head, globals, locals)
  File "/usr/lib/python2.7/", line 9, in <module>
    from operator import itemgetter as _itemgetter
  File "/usr/lib/python2.7/site-packages/mercurial/", line 114, in _demandimport
    mod = _origimport(name, globals, locals)
ImportError: /usr/lib/python2.7/site-packages/ undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString

I tried to fix it compiling python with --enable-unicode=ucs4, but didn't work. After an hour trying to fix this in /usr/lib, I realised
I could try to fix it in a virtualenv, it's a great way to have everything under control in any of your python projects and I've been using
it for every project.

My final solution was as easy as...

$ virtualenv2 ~/.virtualenvs/mercurial
$ workon mercurial # Or ~/.virtualenvs/mercurial/bin/activate
$ cd Mercurial-3ee5d3c372fa/ # tarball from
$ python install

That's it! it runs smoothly now.

UPDATE: Once I could isolate the problem I realised it had to be with some kind of problem with an import for SSL, I moved the file and installed the Mercurial tarball I downloaded previously in my virtualenv (and worked there), I think the problem is solved now, It seemed a compilation build was done in a wrong place. :-)

Javier Aguirre

Read more posts by this author.

comments powered by Disqus