Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

eclipse

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.

like image 734
MdaG Avatar asked Dec 01 '10 12:12

MdaG


People also ask

How do I create a PyDev project in Eclipse?

Create a new projectGo to File → New → PyDev Project to start a wizard. In the next window that appears, enter the name of your project and select "python" and 3.0"; as the type. Make sure "create default 'src' folder and add it to the pythonpath?" is selected. Click Finish.

What is PyDev Eclipse?

PyDev is a third-party plug-in for Eclipse. It is an Integrated Development Environment (IDE) used for programming in Python supporting code refactoring, graphical debugging, code analysis among other features.

What is PyDev project?

pydevproject file will be also be created. This file is used to define which interpreter to use for your project, the location of your project's python source files, and the location of any third party libraries your project requires (if not already on your project's interpreter path).


2 Answers

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?

like image 146
Fabio Zadrozny Avatar answered Sep 24 '22 14:09

Fabio Zadrozny


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

like image 40
mihir Avatar answered Sep 26 '22 14:09

mihir