I have a server running on Ubuntu 10.04 on which I wanted to install Mercurial via
% sudo apt-get install mercurial
It seems to have installed successfully and doesn't show me any error messages. But when I try it I get:
% hg
abort: couldn't find mercurial libraries in [/usr/bin /usr/lib/python2.6 /usr/lib/python2.6/plat-linux2 /usr/lib/python2.6/lib-tk /usr/lib/python2.6/lib-old /usr/lib/python2.6/lib-dynload /usr/lib/python2.6/dist-packages /usr/lib/pymodules/python2.6 /usr/local/lib/python2.6/dist-packages]
(check your install and PYTHONPATH)
I've googled for a while now and found some sites with the same problem but I still have no idea on how to fix it since it nowhere really says what I need to look for or what I need to add to my PYTHONPATH...
By the way, right now my PYTHONPATH seems to be empty:
% echo $PYTHONPATH
%
This is what I get if I look into my /usr/lib/ directory for mercurial:
% find /usr/lib/py* -name 'mercurial*'
/usr/lib/pymodules/python2.6/mercurial
/usr/lib/pymodules/python2.6/mercurial-1.4.3.egg-info
/usr/lib/pyshared/python2.6/mercurial
Can anybody please help me with that? What (and how) should I set my PYTHONPATH to? I already tried reinstalling, installing with "easy_install mercurial" or with "aptitude reinstall mercurial" but nothing helped. I always get this same error.
Would be great if anyone could help... thanks!
ADDITION:
Building from scratch didn't work out well... when I am logged in as root I can use hg, but when I access with my normal user I get:
% hg
Traceback (most recent call last):
File "/usr/local/bin/hg", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2659, in <module>
parse_requirements(__requires__), Environment()
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: mercurial==1.7.2
I'm not sure about the precise reason for this, but I've worked around a similar problem by installing Mercurial from source (you may want to remove any Mercurial packages first, though).
Download the Mercurial tarball here and extract it:
...this should do it. If you have several versions of python installed (2.5, 2.6, 2.7), use the latest one.
Something like this happened to me in OS X when I gave the system Python first priority over the version of python I had installed with Homebrew. I should have prepended the Homebrew version to PATH instead of postpending it. More info at https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python.
So in
.bash_profile
or the similar rc file, I changed the order ofto
and then Mercurial stopped throwing that error.
(I hope vou've solved this by now, but I'll try giving some advice about how to find Mercurial anyway.)
First: please come to the IRC channel if you run into this kind of problem. That's much better than trying random things to make it work — installing things here and there will only make you and your system more confused :-)
It sounds like you've tried many different things to install Mercurial. Be very careful with mixing different ways of installing Mercurial (or any other Python program, for that matter). The second error you get is because you're starting one version of Mercurial (version 1.7.2) and it's finding older libraries. So you've probably got two more or less working installations by now.
So my advice would be to remove the Ubuntu package and remove any other versions of Mercurial. Search for directories and files called
mercurial
and delete them (but delete the package first, of course).Then install the package — if the version in Ubuntu's normal repository is too old, then use the Mercurial PPA. The first error you got means that Mercurial cannot find it's libraries (this is of course strange and unexpected when you install Mercurial from an Ubuntu package). Try running
to see if you can import the
mercurial
package yourself. If that works, then you'll see where the package lives and you can add the parent directory to yourPYTHONPATH
:If that doesn't work, then search for
commands.py
. That is a file in Mercurial and the grand-parent directory of that file should be on yourPYTHONPATH
.That should get you up and running... but, again, it's not expected that you have to fiddle with this yourself when you install Mercurial using a package manager.
I had exactly the same issue and this is what seemed got it working (could be that there was something else which i did but I cant recall now):
Just add the Mercurial lib Path to PYTHONPATH.
locate mercurial
, and find the Lib PATH. E.g. /usr/lib64/python2.6/site-packages/mercurial ;export PYTHONPATH=$PYTHONPATH:/usr/lib64/python2.6/site-packages
.The Lib path may be a different place in your machine. And you could permanently add the export sentence to ~/.bashrc or ~/.zshrc .
I was getting this error as well, and reinstalling, removing/installing didn't help. It turned out that my system had Python2.3 and Python2.4 installed. It was using Python2.4, but the mercurial libraries were installed in Python2.3. I copied the mercurial libraries to Python2.4, and it fixed the problem. Here are the commands I used to copy the libraries:
cd /usr/lib64/python2.4/site-packages sudo cp -r /usr/lib64/python2.3/site-packages/mercurial .