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

这一生的挚爱 提交于 2019-12-29 08:31:47

问题


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.


回答1:


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?




回答2:


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




回答3:


(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


来源:https://stackoverflow.com/questions/4324502/most-efficient-way-of-setting-up-a-project-pydev-pythonpath-in-eclipse-helios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!