0

I have the following project structure:

Project
  - GUI
    - ...Modules
  - Data
    - Database
      - ...Modules
    - Files
      - ...Modules
  - Utilities
    - ...Modules

And I am trying to do some imports over package borders, for example:

in the file(Module) Project.Database.dbdriver I try to import Project.Utilities.Conversions. If I use a fully specified import like import Project.Utilities.Conversions this fails, it works with import Utilities.Conversions, i.e. I can not specify more off the path than those part that differ. However I would like to use fully specified paths, one reason beeing that pydev in eclipse likes them better (otherwise it shows me an error), the second reason is I find it confusing not to do so.

I have stumbled over this but think it is wrong/not needed here How do I create a namespace package in Python?

Question: how can I use fully specified includes when crossing subbranches in a package structure?

Community
  • 1
  • 1
ted
  • 4,791
  • 5
  • 38
  • 84

1 Answers1

1

The fully specified import failed because the current working directory of python(or jython) was set to Project. you can:

add the parent directory of Project to your python lib

import sys
sys.path.append('/parent/of/project')

or just change the working directory of jython to the parent of Project in the debug settings.(I don't know how to do it because I don't use pydev.)

acui
  • 26
  • 3
  • the problem was not with pydev, but with the shell in which I ran the project. (outside eclipse). Thank you. – ted Jun 15 '12 at 09:58
  • while your suggestion fixed my problem in the application I am developing for it created a problem within pydev, `import Project.GUI as gui` yields `ImportError: No module named GUI`, and yes there is `__init__.py` and yes the projects parent folder shows up when I `print sys.path`, right before the error. But I will put that somewhere else sinc e you solved the initial question – ted Jun 15 '12 at 14:31