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

        <bdo id='83HvV'></bdo><ul id='83HvV'></ul>

      <small id='83HvV'></small><noframes id='83HvV'>

        PyDev for Eclipse - 解决 Python 依赖项(未解决的导入)

        PyDev for Eclipse - Resolve Python dependencies (unresolved imports)(PyDev for Eclipse - 解决 Python 依赖项(未解决的导入))

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

                  <tfoot id='JNLDE'></tfoot>
                  本文介绍了PyDev for Eclipse - 解决 Python 依赖项(未解决的导入)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用 PyDev for Eclipse 作为我的 IDE 和 pip 作为我的包管理工具,运行 virtualenv.

                  I am using PyDev for Eclipse as my IDE and pip as my package management tool, running virtualenv.

                  每次我想在我的项目中使用/包含一些新库或新依赖项时,我都会将它们添加到 pip-requires 文件中.运行 pip install -r pip-requires 后,依赖项安装在我的虚拟环境中没有问题.

                  Every time I want to use/include some new libraries or new dependencies in my project, I add them into the pip-requires file. The dependencies are installed in my virtual environment with no problem after running pip install -r pip-requires.

                  我的环境:

                  • Ubuntu 12.04
                  • PyDev for Eclipse 2.7.1.2012100913
                  • Python 2.7.3
                  • 日蚀靛蓝

                  更新:我的 Pydev 设置:

                  问题:

                  • eclipse/pydev 对添加到我的虚拟环境中的新库一无所知.我不得不手动将 .egg 源文件夹一一添加到 Eclipse 项目的 PYTHONPATH 中,以解决所有未解决的导入问题,这非常烦人!能否以更简单的方式解决 python 依赖项?
                  • eclipse/pydev knows nothing about the new libraries being added in my virtual env. I had to manually add the .egg source folder into eclipse project's PYTHONPATH one by one in order to resolve all the unresolved imports which was very annoying! Can the python dependencies be resolved in a easier manner?

                  更新:

                  • 我发现如果我使用虚拟环境 Env/bin/python 作为屏幕截图所示的解释器,则某些基本模块在 eclipse 中无法解析,例如.import copy, import json 等我应该使用默认的 /usr/bin/python 作为解释器,只需将虚拟环境 site-package 添加到蟒蛇路径?这样我就可以解决标准python库(例如json)和我自己的项目依赖项?
                  • I found that if I use virtual env Env/bin/python as the interpreter as the screenshot indicates, some of the basic modules are not resolved in eclipse, eg. import copy, import json etc. should I use default /usr/bin/python as interpreter and just add virtual env site-package to the PYTHONPATH? so that I can resolve both standard python libraries(eg. json) and my own project dependencies?

                  推荐答案

                  当您从 virtualenv 中选择 python 解释器时,请确保您的系统 PYTHONPATH 包含 site-packages 文件夹.就像快照一样.

                  Make sure your system PYTHONPATH include the site-packages folder when you choose python interpreter from your virtualenv. Just like the snapshot.

                  那么你就不需要将它们一一添加到 PYTHONPATH 中了.您将需要重新启动 Eclipse(刷新不起作用).将添加新模型.

                  Then you don't need to add them one by one into PYTHONPATH. You will need to restart eclipse (Refresh doesn't work). New models will be added.

                  更新:我检查了 virtualenv 中的 PYTHONPATH.我发现 sys.path 中还有其他一些路径.它们是系统默认的 python 安装位置.这些路径包括基本模型,如 copyjson.

                  Update: I checked the PYTHONPATH in the virtualenv. I found there are some other paths in the sys.path. They are the system default python installed location. These path includes the basic models, like copy and json.

                  PS:我的环境是 Max OSX 10.8.请通过print sys.path

                  PS: My environment is Max OSX 10.8. Please check the output of your own platform by print sys.path

                  /Users/username/.virtualenvs/test/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
                  /Users/username/.virtualenvs/test/lib/python2.7/site-packages/pip-1.1-py2.7.egg
                  /Users/username/.virtualenvs/test/lib/python27.zip
                  /Users/username/.virtualenvs/test/lib/python2.7
                  /Users/username/.virtualenvs/test/lib/python2.7/plat-darwin
                  /Users/username/.virtualenvs/test/lib/python2.7/plat-mac
                  /Users/username/.virtualenvs/test/lib/python2.7/plat-mac/lib-scriptpackages
                  /Users/username/.virtualenvs/test/lib/python2.7/lib-tk
                  /Users/username/.virtualenvs/test/lib/python2.7/lib-old
                  /Users/username/.virtualenvs/test/lib/python2.7/lib-dynload
                  /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7
                  /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
                  /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
                  /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
                  /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
                  /Users/username/.virtualenvs/test/lib/python2.7/site-packages
                  

                  我认为这是 virtualenv 的要求.您需要将这些路径添加到 pydev 系统 PYTHONPATH 中.然后就可以使用这些基本模块了.

                  I think this is the requirement of virtualenv. You need to add these paths into pydev system PYTHONPATH. Then you can use these basic modules.

                  这篇关于PyDev for Eclipse - 解决 Python 依赖项(未解决的导入)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Bytecode features not available in the Java language(Java 语言中不可用的字节码功能)
                  ClassCastException because of classloaders?(ClassCastException 因为类加载器?)
                  How can I add a Javaagent to a JVM without stopping the JVM?(如何在不停止 JVM 的情况下将 Javaagent 添加到 JVM?)
                  Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                  Encourage the JVM to GC rather than grow the heap?(鼓励 JVM 进行 GC 而不是增加堆?)
                  Why a sawtooth shaped graph?(为什么是锯齿形图形?)

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

                    <legend id='BCwFD'><style id='BCwFD'><dir id='BCwFD'><q id='BCwFD'></q></dir></style></legend>
                      <tbody id='BCwFD'></tbody>
                    • <bdo id='BCwFD'></bdo><ul id='BCwFD'></ul>

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