This is deprecated: it still works, but see my later post about referencing Eclipse PyDev projects.
Suppose you have two Python projects in the Eclipse IDE and you are using the PyDev plugin for Eclipse. You want to import one project from another.
One way to do it:
- in first project, in Eclipse, created a linked folder to the source subfolder of the second project, containing a module named foo.
- in the first project, in Eclipse, add the linked folder to Properties> PyDev PYTHON_PATH> Source folders
- in the first project, in some file, use “from foo import FooClass”
This is what your Eclipse directory tree looks like (in the PyDev Package Explorer frame):
FirstProject > packageFoo packageBar __init__.py bar.py SecondProject packageFoo __init__.py foo.py
Here, the indentation level shows the tree structure, and the “>” is the icon that Eclipse uses to indicate a linked folder. In bar.py, you find the code:
from foo import FooClass
Note that you import module foo, not packageFoo.foo (since packageFoo is in PYTHON_PATH, its modules can be imported.)
Note that the packages ARE packages because they include a file named __init__.py. That file typically is empty.