python - Volttron-拒绝以root身份运行以防止潜在损害

标签 python git error-handling terminal volttron

我在VM上运行Ubuntu Desktop 16.04,并尝试使用标准安装说明运行Volttron,但是在执行以下步骤后,我仍然收到错误消息:

sudo apt-get update
sudo apt-get install build-essential python-dev openssl libssl-dev libevent-dev git
git clone https://github.com/VOLTTRON/volttron
cd volttron
python bootstrap.py

我的问题是最后一步python bootstrap.py。一旦执行此步骤,就会从终端窗口中收到错误bootstrap.py: error: refusing to run as root to prevent potential damage.

还有其他人遇到过这个问题吗?有什么想法吗?

最佳答案

这来自this part of bootstrap.py (和this commit)

# Refuse to run as root
if not getattr(os, 'getuid', lambda: -1)():
    sys.stderr.write('%s: error: refusing to run as root to prevent '
                     'potential damage.\n' % os.path.basename(argv[0]))
    sys.exit(77)

因此,请检查您是否确实有 os.getuid (当前进程的真实用户ID),因为 getattr 提到:

If the named attribute does not exist, default is returned if provided, otherwise AttributeError is raised.



参见“What is difference between os.getuid() and os.geteuid() ?”。
也许您的终端窗口是作为root启动的。 (检查id -a的输出)

关于python - Volttron-拒绝以root身份运行以防止潜在损害,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45155336/

相关文章:

git - 在 Git 中进行硬重置后,是否有办法截断分支以使其不反射(reflect)快进?

git - 恢复通过 git -f --mirror 在远程 Github 存储库上删除的分支

git - 切换到分支时如何保持忽略的文件而不忽略它们?

vba - 失去与SharePoint问题的连接

python - 处理来自Python列表框的错误

python - 在 python : How to perform regular expression search on "circular" string

python - 如何使用 YAML 配置 Python 日志记录以登录 UTC?

python - python中的多项式回归模型

javascript - 处理未定义网址的错误

python - 如果字符存在,则捕获字符后的所有内容