如何纠正损坏的 $PYTHONPATH?

发布于 2024-08-13 09:30:11 字数 1954 浏览 9 评论 0原文

在我的 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']

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

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

提前致谢。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

倾城花音 2024-08-20 09:30:11

试试这个:

update-python-modules -p

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

Try this:

update-python-modules -p

(might need to sudo that...)
Source:
http://hg.opensource.lshift.net/mercurial-server/rev/32dba1a70a54

灵芸 2024-08-20 09:30:11

我用谷歌搜索过的所有网站都说您的 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 没有提及 Mercurial。据猜测,我会将其添加到您的 PYTHONPATH:

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

并且我会从 make 重新安装 Mercurial。这个建议在这里效果很好。

编辑:在我的 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

All of the sites I've googled for this say that your PYTHONPATHis 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.

甜柠檬 2024-08-20 09:30:11

Mercurial 是否位于库安装路径之一(dist-packagessite-packages)?可以使用find工具来查找吗?

您是否幸运地安装了小型库并在这台机器上通过 Python 访问它们?

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?

零度℉ 2024-08-20 09:30:11

感谢大家的努力。

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

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

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.

赠佳期 2024-08-20 09:30:11

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

sudo aptitude reinstall mercurial

You could try to reinstall affected Python programs with aptitude:

sudo aptitude reinstall mercurial
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文