在Eclipse(Helios)中设计项目Pydev PYTHONPATH的最有效的方法? [英] Most efficient way of setting up a project Pydev PYTHONPATH in Eclipse (Helios)?

查看:167
本文介绍了在Eclipse(Helios)中设计项目Pydev PYTHONPATH的最有效的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Pydev项目中的所有文件夹添加到PYTHONPATH,以便轻松查看未使用的导入等功能。为此,我似乎必须逐个手动添加所有文件夹,包括子文件夹。有没有办法一次性(递归地)添加它们,或者我完全错了?



现在我右键点击导航器偏好设置。从那里我去 Pydev-PYTHONPATH ,最后我可以添加文件夹。

解决方案

只是给出一个正确的答案,你应该添加你想要在PYTHONPATH中的文件夹作为源文件夹。



所以,如果您有一个结构,如

  / myproject 
/ myproject / src
/ myproject / package
/myproject/package/__init__.py
/ myproject / package2
/myproject/package2/__init__.py

你只需要添加/ myproject / src作为你的PYTHONPATH。



如果你真的有多个文件夹添加到那里,你可以编辑.pydevproject文件(它位于项目的根目录),同时在其中添加多个文件夹(尽管如上所述,您应该只有几个文件夹,因此通常不需要 - 尽管有时您可能想要如果你要添加多个库到一个文件夹或类似的东西)。



PyDev常见问题解答可以正确地解释下列项目:




  • 如何将现有项目/来源导入PyDev?


  • 将Django项目的现有项目/来源导入PyDev?



I want to add all folders in my Pydev project to PYTHONPATH so that I can reap the benefits of easily seeing unused imports etc. To do this I seemingly have to add all folders manually including the subfolders, one by one. Is there any way to add them all at once (recursively) or am I doing this completely wrong?

Now I right click the project in the Navigator and select Preferences. From there I go to Pydev-PYTHONPATH and finally I can add the folders.

解决方案

Ok, just to give a proper answer, you should just add the folder(s) that you want to be in the PYTHONPATH as your source folder(s).

So, if you have a structure such as

/myproject
/myproject/src
/myproject/package
/myproject/package/__init__.py
/myproject/package2
/myproject/package2/__init__.py

You'd only want to add /myproject/src as your PYTHONPATH.

If you really had multiple folders to add there, you could edit the .pydevproject file (which is at the root of your project) and add multiple folders there at once (although as noted, you should only have few folders there, so, this is generally not needed -- although sometimes you may want that if you're adding multiple libraries to a folder or something alike).

The PyDev FAQ explains this properly on the items listed below:

  • How do I import existing projects/sources into PyDev?

  • How do I import existing projects/sources for a Django project into PyDev?

这篇关于在Eclipse(Helios)中设计项目Pydev PYTHONPATH的最有效的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆