6

在我的 Ubuntu 9.10 Linux Box 中重新启动后尝试启动 Mercurial(hg) 时,我收到以下消息:

      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)

奇怪的是,其他 Python 程序找不到它们的模块,包括 django-admin、bzr,但令人惊讶的是 Python 解释器本身正在启动。

在这里你可以找到我当前的 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']

有谁知道如何解决这个问题?

我知道这不是具体的编程问题,但它不允许我编程,所以我请求你的理解!

提前致谢。

4

5 回答 5

8

尝试这个:

更新python模块-p

(可能需要 sudo ......)来源: http ://hg.opensource.lshift.net/mercurial-server/rev/32dba1a70a54

于 2011-10-13T23:17:35.100 回答
5

我为此搜索过的所有网站都说您PYTHONPATH的设置错误。您在 mercurial 中遇到的代码似乎是这样的:

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)

那么demandimport你的机器在哪里?在我的 windows 盒子上,它在这里:

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

这很有效,因为我的 PYTHONPATH 中有 mercurial:

>>> 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

PYTHONPATH没有提到善变。猜测一下,我会将其添加到您的 PYTHONPATH 中:

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

我会从make. 这个建议在这里很有效。

编辑:在我的 Ubuntu 9.10 机器上,我得到了这些结果:

>>> 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

这让我觉得问题是你缺少这个:/usr/lib/pymodules/python2.6

于 2009-12-04T15:54:07.610 回答
1

感谢大家的努力。

多亏了hughdbrown ,我已经解决了这个问题。hughdbrown,你让我意识到我在定义 $PYTHONPATH 时犯了一个错字;我没有添加路径 /usr/lib/pymodules/ python2.6,而是写了 /usr/lib/pymodules/ 所以python无法导入库......但是,我更正了它,我很高兴看到 Mercurial 和再次合作。

唯一奇怪的是,为什么它改变了......好吧,我从现在开始知道该怎么做。

于 2009-12-04T17:47:30.810 回答
1

mercurial 是否位于库安装路径之一(dist-packagessite-packages)中?你可以用find工具来寻找吗?

您是否有幸在这台机器上安装了小型库并从 Python 访问它们?

于 2009-12-04T14:35:48.847 回答
0

您可以尝试使用 aptitude 重新安装受影响的 Python 程序:

sudo aptitude reinstall mercurial
于 2009-12-04T14:44:25.277 回答