如何纠正损坏的 $PYTHONPATH?
在我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
试试这个:
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
我用谷歌搜索过的所有网站都说您的
PYTHONPATH
设置错误。您在 Mercurial 中输入的代码似乎是这样的:那么您的计算机上的
demandimport
在哪里?在我的 Windows 盒子上,它在这里:这之所以有效,是因为我的 PYTHONPATH 中有 Mercurial:
您的
PYTHONPATH
没有提及 Mercurial。据猜测,我会将其添加到您的 PYTHONPATH:并且我会从
make
重新安装 Mercurial。这个建议在这里效果很好。编辑:在我的 Ubuntu 9.10 盒子上,我得到了这些结果:
这让我认为问题是你缺少这个:
/usr/lib/pymodules/python2.6
。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:So where is
demandimport
on your machine? On my windows box, it is here:And that works because I have mercurial in my PYTHONPATH:
Your
PYTHONPATH
makes no mention of mercurial. At a guess, I would add this to your PYTHONPATH: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:
And this makes me think the problem is that this is missing for you:
/usr/lib/pymodules/python2.6
.Mercurial 是否位于库安装路径之一(
dist-packages
或site-packages
)?可以使用find
工具来查找吗?您是否幸运地安装了小型库并在这台机器上通过 Python 访问它们?
Is mercurial located in one of the library installation paths (
dist-packages
orsite-packages
)? You can use thefind
tool to look for it?Did you have luck installing small libraries and access them from Python on this machine?
感谢大家的努力。
感谢 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.
您可以尝试使用 aptitude 重新安装受影响的 Python 程序:
You could try to reinstall affected Python programs with aptitude: