1. <legend id='HwlfU'><style id='HwlfU'><dir id='HwlfU'><q id='HwlfU'></q></dir></style></legend>

        • <bdo id='HwlfU'></bdo><ul id='HwlfU'></ul>
        <i id='HwlfU'><tr id='HwlfU'><dt id='HwlfU'><q id='HwlfU'><span id='HwlfU'><b id='HwlfU'><form id='HwlfU'><ins id='HwlfU'></ins><ul id='HwlfU'></ul><sub id='HwlfU'></sub></form><legend id='HwlfU'></legend><bdo id='HwlfU'><pre id='HwlfU'><center id='HwlfU'></center></pre></bdo></b><th id='HwlfU'></th></span></q></dt></tr></i><div id='HwlfU'><tfoot id='HwlfU'></tfoot><dl id='HwlfU'><fieldset id='HwlfU'></fieldset></dl></div>
      2. <small id='HwlfU'></small><noframes id='HwlfU'>

        <tfoot id='HwlfU'></tfoot>
      3. sudo python 运行旧的python版本

        时间:2023-09-14

          <legend id='BcZ9N'><style id='BcZ9N'><dir id='BcZ9N'><q id='BcZ9N'></q></dir></style></legend>
          <tfoot id='BcZ9N'></tfoot>
            <tbody id='BcZ9N'></tbody>

            <small id='BcZ9N'></small><noframes id='BcZ9N'>

            • <i id='BcZ9N'><tr id='BcZ9N'><dt id='BcZ9N'><q id='BcZ9N'><span id='BcZ9N'><b id='BcZ9N'><form id='BcZ9N'><ins id='BcZ9N'></ins><ul id='BcZ9N'></ul><sub id='BcZ9N'></sub></form><legend id='BcZ9N'></legend><bdo id='BcZ9N'><pre id='BcZ9N'><center id='BcZ9N'></center></pre></bdo></b><th id='BcZ9N'></th></span></q></dt></tr></i><div id='BcZ9N'><tfoot id='BcZ9N'></tfoot><dl id='BcZ9N'><fieldset id='BcZ9N'></fieldset></dl></div>
                <bdo id='BcZ9N'></bdo><ul id='BcZ9N'></ul>
                • 本文介绍了sudo python 运行旧的python版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我已经按照这些说明在 CentOS 6 上安装了 python 2.7.3

                  I have installed python 2.7.3 on CentOS 6 with thse instructions

                  http://villaroad.com/2010/10/rolling-python-2-6-2-on-centos-5-3/

                  我已经为新 python 的 root 和 myuser 的 bash_profile 添加了别名.现在,当我将 python 写入 shell 时,它可以从两个用户正确运行 python2.7.3.

                  I have added aliases to bash_profile of both root and myuser for new python. Now when I write python to shell, it runs python2.7.3 correctly from both users.

                  但是,如果我写 sudo python 它仍然运行旧版本 python2.6.6

                  However, if I write sudo python it stills runs old version python2.6.6

                  可能是什么问题?

                  推荐答案

                  sudo 不使用你的 shell 来运行命令,它只是 exec 直接执行命令.这意味着 (a) 没有任何源代码来自 root 的 bash_profile,因此放在那里的内容无关紧要,并且 (b) 即使设置了 shell 别名也无关紧要.

                  sudo doesn't use your shell to run commands, it just execs the command directly. This means (a) there's nothing that sources root's bash_profile, so it doesn't matter what you put there, and (b) shell aliases wouldn't matter even if they were set.

                  因此,如果您想使用 aliases 指定与 PATH 中的 Python 不同的 Python,则不能使用 sudo python 来运行相同的 Python一个.

                  So, if you want to use aliases to specify a different python than the one that's on your PATH, you can't use sudo python to run that same one.

                  最简单,也可能是最安全的修复方法是明确的:运行 sudo/path/to/other/python.如果您需要经常这样做,您可以随时为其创建别名.

                  The easiest, and probably safest, fix is to be explicit: run sudo /path/to/other/python. If you need to do this often enough, you can always create an alias for that.

                  如果你真的想要,可以sudo 使用 shell.显式生成运行 pythonbash 命令行,或者(更简单地)只使用 -s-i标志.(在这种情况下,如果你试图让 root 的 ~/.bash_profile 运行,-s 不会这样做,但 -i 会.)但是 sudo 执行 shell 不如 sudo 执行程序安全.您的 sudoers 甚至可能被显式配置为阻止您这样做.(如果你愿意,你可以用 visudo 来解决这个问题,但是在不确切了解你正在打开什么的情况下打开一个安全漏洞通常被认为是一件坏事.)

                  If you really want to, you can make sudo use a shell. Either explicitly generate the bash command line that runs python, or (more simply) just use the -s or -i flags. (In this case, if you're trying to get root's ~/.bash_profile run, -s won't do it, but -i will.) But sudoing shells is not as safe as sudoing programs. Your sudoers may even be explicitly configured to prevent you from doing it. (You can fix that with visudo if you want, but opening a security hole without understanding exactly what you're opening is generally considered a bad thing to do.)

                  这篇关于sudo python 运行旧的python版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <tbody id='AY4x7'></tbody>
                  <tfoot id='AY4x7'></tfoot>

                    <i id='AY4x7'><tr id='AY4x7'><dt id='AY4x7'><q id='AY4x7'><span id='AY4x7'><b id='AY4x7'><form id='AY4x7'><ins id='AY4x7'></ins><ul id='AY4x7'></ul><sub id='AY4x7'></sub></form><legend id='AY4x7'></legend><bdo id='AY4x7'><pre id='AY4x7'><center id='AY4x7'></center></pre></bdo></b><th id='AY4x7'></th></span></q></dt></tr></i><div id='AY4x7'><tfoot id='AY4x7'></tfoot><dl id='AY4x7'><fieldset id='AY4x7'></fieldset></dl></div>

                      <legend id='AY4x7'><style id='AY4x7'><dir id='AY4x7'><q id='AY4x7'></q></dir></style></legend>

                      <small id='AY4x7'></small><noframes id='AY4x7'>

                        • <bdo id='AY4x7'></bdo><ul id='AY4x7'></ul>