How to fix damaged $ PYTHONPATH?

When I tried to run Mercurial (hg) after a reboot in my Ubuntu 9.10 Linux Box, I received the 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 do not find their modules, including django-admin, bzr, BUT it is surprising that the Python interpreter itself launches.

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 know how to solve this problem?

I know that this is not a programming issue in the concrete, but it forbids me to program, so I ask your understanding!

Thanks in advance.

+6
python version-control mercurial pythonpath
source share
5 answers

Try the following:

update-python-modules -p

(sudo may be required, that ...) Source: http://hg.opensource.lshift.net/mercurial-server/rev/32dba1a70a54

+8
source share

All the sites that I searched for this say that your PYTHONPATH is not installed correctly. The code you click in the mercury looks like 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 the demandimport on your machine? On my window window 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 this works because I have Mercury 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 does not mention mercury. I suppose I would add this to your PYTHONPATH:

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

and I would reinstall mercurial from make . This tip worked well here .

Edit: And in my Ubuntu 9.10, I got the following 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 that makes me think that the problem is that you are missing it: /usr/lib/pymodules/python2.6 .

+5
source share

Is Mercury located on one of the library installation paths ( dist-packages or site-packages )? Can you use the find tool to find it?

Are you lucky with installing small libraries and accessing them with Python on this computer?

+1
source share

Thanks for all the efforts.

I solved the problem thanks to hughdbrown . hughdbrown, you made me realize that I made a typo in determining the execution of $ PYTHONPATH; instead of adding the path / usr / lib / pymodules / python2.6 , I wrote / usr / lib / pymodules /, so python could not import the libraries ... However, I fixed it and I am glad to see that Mercurial and Co are working again .

The only strange thing is: WHY it has changed ... Well, now I will know what to do.

+1
source share

You can try reinstalling the affected Python programs with aptitude:

 sudo aptitude reinstall mercurial 
0
source share

All Articles