使用非 root 用户访问 Mercurial 时出错

发布于 2024-10-01 16:19:41 字数 723 浏览 0 评论 0原文

我试图让非 root 用户能够从 shell 运行 Mercurial 命令。当我以用户身份登录并输入“hg”时,我收到以下消息:

abort: couldn't find mercurial libraries in [/usr/local/bin /usr/lib/python24.zip /usr/lib/python2.4 /usr/lib/python2.4/plat-linux2 /usr/lib/python2.4/lib-tk /usr/lib/python2.4/lib-dynload /usr/lib/python2.4/site-packages /usr/lib/python2.4/site-packages/Numeric /usr/lib/python2.4/site-packages/gtk-2.0]
(check your install and PYTHONPATH)

我作为 root 没有遇到此问题。我可以从任何目录运行 Mercurial 命令。

我的问题是我对 Linux 一点也不熟悉,所以我不知道应该如何更改我的 PYTHONPATH 变量(如果这确实是我想要做的)。我什至不知道 PYTHONPATH 变量存储在哪里以查看现在写的内容。

有人可以告诉我 PYTHONPATH (甚至常规 PATH)环境变量存储在 Linux 中的位置,以及我可以采取哪些步骤来删除上面遇到的错误方法?如果有帮助,我将使用 Putty 和 SSH 来访问服务器。

谢谢! :)

I am trying to give a non-root user the ability to run mercurial commands from the shell. When I log in as the user and type "hg", I get this message:

abort: couldn't find mercurial libraries in [/usr/local/bin /usr/lib/python24.zip /usr/lib/python2.4 /usr/lib/python2.4/plat-linux2 /usr/lib/python2.4/lib-tk /usr/lib/python2.4/lib-dynload /usr/lib/python2.4/site-packages /usr/lib/python2.4/site-packages/Numeric /usr/lib/python2.4/site-packages/gtk-2.0]
(check your install and PYTHONPATH)

I do not have this problem as the root. I can run mercurial commands from any directory.

My problem is that I'm not very familiar with Linux at all, and so I don't know exactly how I'm supposed to change my PYTHONPATH variable (if indeed that's what I'm trying to do). I don't even know where the PYTHONPATH variable is being stored to see what's written there now.

Can someone tell me where the PYTHONPATH (or even regular PATH) environment variable is stored in Linux, and what steps I might take to remove the error method I'm getting above? If it helps, I'm using Putty and SSH to access the server.

Thanks! :)

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

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

发布评论

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

评论(1

七堇年 2024-10-08 16:19:41

PYTHONPATH 只是一个 环境变量 添加到 python 的内部搜索路径中。要查看其中的内容,请在 python shell 中执行以下操作:

>>> import sys
>>> sys.path

它应该打印类似以下内容:

['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/PIL', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib64/python2.7/site-packages/webkit-1.0', '/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']

实际上,我猜您的 shell 是 bash,因此可以设置环境变量的位置是:
/etc/profile/etc/bashrc~/.profile~/.bashrc - 第一个2 是系统范围的,后者是每个用户的。

有关进一步的说明,请参阅这篇关于 bashrc 和配置文件的博客文章

编辑
要解决这个问题,最简单的方法可能是通过 pip 安装 Mercurial(我假设您的 Linux 发行版的官方存储库中没有 Mercurial,但通常是 python-setuptools 或类似的,即提供了easy_install)。有关说明,请参阅此问题

The PYTHONPATH is just an environment variable that gets prepended to the python's internal search path. To see what is in there, do the following in python shell:

>>> import sys
>>> sys.path

It should print something like:

['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/PIL', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib64/python2.7/site-packages/webkit-1.0', '/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']

In practice, I would guess your shell is bash so the places where the environment variables can be set are:
/etc/profile, /etc/bashrc, ~/.profile and ~/.bashrc - the first 2 being system wide and the latter per user.

For further explanation, see this blog article abour bashrc and profile

EDIT
To fix this, the probably the easiest way is to install Mercurial via pip (I am assuming that you do not have Mercurial in the official repository for your Linux distribution, but usually python-setuptools or similar, that provides easy_install is). See this question for instructions.

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