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

      2. <small id='tCY0h'></small><noframes id='tCY0h'>

        如何刷新 sys.path?

        时间:2023-09-14
        <legend id='4b5FN'><style id='4b5FN'><dir id='4b5FN'><q id='4b5FN'></q></dir></style></legend>

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

              <small id='4b5FN'></small><noframes id='4b5FN'>

              <tfoot id='4b5FN'></tfoot>
                <tbody id='4b5FN'></tbody>
                <bdo id='4b5FN'></bdo><ul id='4b5FN'></ul>

                • 本文介绍了如何刷新 sys.path?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在以用户身份执行脚本的过程中安装了一些软件包.这些包是第一个用户包,所以 python 在脚本运行之前没有将 ~/.local/lib/python2.7/site-packages 添加到 sys.path.我想导入那些已安装的软件包.但我不能,因为它们不在 sys.path 中.

                  I've installed some packages during the execution of my script as a user. Those packages were the first user packages, so python didn't add ~/.local/lib/python2.7/site-packages to the sys.path before script run. I want to import those installed packages. But I cannot because they are not in sys.path.

                  如何刷新 sys.path?

                  我使用的是 python 2.7.

                  I'm using python 2.7.

                  推荐答案

                  如 什么时候用 Python 设置 sys.path,什么时候? sys.path 在内置 site.py 模块的帮助下填充.

                  As explained in What sets up sys.path with Python, and when? sys.path is populated with the help of builtin site.py module.

                  所以你只需要重新加载它.您不能一步完成,因为您的命名空间中没有 site.总结一下:

                  So you just need to reload it. You cannot it in one step because you don't have site in your namespace. To sum up:

                  import site
                  from importlib import reload
                  reload(site)
                  

                  就是这样.

                  这篇关于如何刷新 sys.path?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:分发带有已编译动态共享库的 Python 包 下一篇:在 OpenShift 上安装 python 包

                  相关文章

                  最新文章

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

                    1. <small id='12H01'></small><noframes id='12H01'>

                      <legend id='12H01'><style id='12H01'><dir id='12H01'><q id='12H01'></q></dir></style></legend>