开发者

Most efficient way of setting up a project Pydev PYTHONPATH in Eclipse (Helios)?

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 开发者_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?


Check this out, this worked for me.

  1. if you get an error “unresolved import: pydevd” try saving the file ‘manage.py’ first. the error should go away.

  2. If the error persists: you need to make sure pydev is in your PYTHONPATH. a) Go to Eclipse>Preferences>PyDev>Python Interpreter: b) Click New Folder> (mac)”/Applications/Eclipse/plugins/org.python.pydev_x.x.x.x/pysrc”

c) Click “Apply” This adds the folder that contains pydevd.py to your PYTHONPATH. Eclipse automatically adds that to your project’s Python Library. This should resolve the problem and you can run it now.

https://djangounchain.files.wordpress.com/2012/12/screen-shot-2013-01-06-at-3-49-02-pm.png


(This should be a Comment to Fabio's answer, but insufficient rep)

(PyDev 2.7.1.2012100913)

Adding folders to the PythonPath does not work for EFS/Remote folders (rse://...)

When you click 'Apply' gives:

An internal error occurred during: "Python Nature: rebuilding modules".
java.lang.NullPointerException
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜