views:

387

answers:

4

Hello,

When trying to launch Mercurial(hg) after a restart in my Ubuntu 9.10 Linux Box I got following message:

      abort: couldn't find mercurial libraries in [/usr/bin /usr/local/lib/python2.6/dist-packages/vipy-0.4-py2.6.egg /usr/local/lib/python2.6/dist-packages/nose-0.11.1-py2.6.egg /usr/local/lib/python2.6/dist-packages/rope-0.9.2-py2.6.egg /usr/local/lib/python2.6/dist-packages/Sphinx-0.6.3-py2.6.egg /usr/local/lib/python2.6/dist-packages/django_html-0.0.1-py2.6.egg /usr/local/lib/python2.6/dist-packages/html5lib-0.11.1-py2.6.egg /home/kenny /home/kenny/Projects/soclone-read-only /home/kenny/python/Django /home/kenny/python/pysmell /home/kenny/python/Django/ropemode /home/kenny/python/Django/rope /home/kenny/python/lib /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/local/lib/python2.6/dist-packages]

      (check your install and PYTHONPATH)

Mysteriously other Python programs don't find their modules, including django-admin, bzr, BUT surprisingly the Python interpreter itself is launching.

Here you can find my current sys.path:

  ['', '/usr/local/lib/python2.6/dist-packages/vipy-0.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/nose-0.11.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/rope-0.9.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Sphinx-0.6.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_html-0.0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/html5lib-0.11.1-py2.6.egg', '/home/kenny', '/home/kenny/Projects/soclone-read-only', '/home/kenny/python/Django', '/home/kenny/python/pysmell', '/home/kenny/python/Django/ropemode', '/home/kenny/python/Django/rope', '/home/kenny/python/lib', '/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/local/lib/python2.6/dist-packages']

Does anyone how to resolve this issue?

I know this is no programming question in specific, but it disallows me to program, so I beg your comprehension!

Thanks in advance.

+1  A: 

Is mercurial located in one of the library installation paths (dist-packages or site-packages)? You can use the find tool to look for it?

Did you have luck installing small libraries and access them from Python on this machine?

Eli Bendersky
A search with find (find /usr/ -name mercurial -type d) gives me the following:./lib/pyshared/python2.5/mercurial./lib/pyshared/python2.6/mercurial./lib/pymodules/python2.6/mercurial./share/mercurial./share/pyshared/mercurialIf you mean with small libraries, libraries from my ~/python/<lib>, then yes, I *can* import them :) . Also essential modules like sys, os, io, all no problem.Most of my libraries are located in /usr/lib/pymodules , but adding this path to $PYTHONPATH after restarting the shell, doesn't solve the problem.Thanks for your effort.!
Kenny M.
Try `/usr/lib/pymodules/python2.6`.
hughdbrown
A: 

You could try to reinstall affected Python programs with aptitude:

sudo aptitude reinstall mercurial
John Paulett
This doesn't solve the problem either ..
Kenny M.
+2  A: 

All of the sites I've googled for this say that your PYTHONPATH is set wrong. The code that you are hitting in mercurial appears to be this:

try:
    from mercurial import demandimport; demandimport.enable()
except ImportError:
    import sys
    sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
                     ' '.join(sys.path))
    sys.stderr.write("(check your install and PYTHONPATH)\n")
    sys.exit(-1)

So where is demandimport on your machine? On my windows box, it is here:

>>> from mercurial import demandimport
>>> demandimport.__file__
'C:\\Python26\\lib\\site-packages\\mercurial-1.4.1-py2.6-win32.egg\\mercurial\\demandimport.pyc'

And that works because I have mercurial in my PYTHONPATH:

>>> import sys
>>> for s in sys.path:
...     print s
...
# Other crud deleted...
C:\Python26\lib\site-packages\mercurial-1.4.1-py2.6-win32.egg
C:\Windows\system32\python26.zip
C:\Python26\DLLs
C:\Python26\lib
C:\Python26\lib\plat-win
C:\Python26\lib\lib-tk
C:\Python26
C:\Python26\lib\site-packages

Your PYTHONPATH makes no mention of mercurial. At a guess, I would add this to your PYTHONPATH:

/usr/local/lib/python2.6/site-packages

and I would re-install mercurial from make. That advice worked well here.

Edit: And on my Ubuntu 9.10 box, I got these results:

>>> import mercurial
>>> mercurial.__file__
'/usr/lib/pymodules/python2.6/mercurial/__init__.pyc'
>>> import sys
>>> for s in sys.path:
...     print s
...

/usr/local/lib/python2.6/dist-packages/pip-0.6.1-py2.6.egg
/usr/local/lib/python2.6/dist-packages/virtualenv-1.4.3-py2.6.egg
/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/python2.6/dist-packages/PIL
/usr/lib/python2.6/dist-packages/gst-0.10
/usr/lib/pymodules/python2.6
/usr/lib/python2.6/dist-packages/gtk-2.0
/usr/lib/pymodules/python2.6/gtk-2.0
/usr/local/lib/python2.6/dist-packages
/usr/local/lib/python2.6/dist-packages/PIL

And this makes me think the problem is that this is missing for you: /usr/lib/pymodules/python2.6.

hughdbrown
+1  A: 

Thanks for the effort to all of you.

I've solved the problem thanks to hughdbrown. hughdbrown, you've made me realize that I commited a typo when defining doing $PYTHONPATH; instead of adding the path /usr/lib/pymodules/python2.6, I wrote /usr/lib/pymodules/ so python couldn't import the libraries... However, I corrected it and I'm glad to see Mercurial and Co. work again.

The only strange thing is, WHY it changed... Well, I'll be knowing from now on what to do.

Kenny M.