On Feb 7, 2008 3:57 PM, Larry Bates <larry.bates@...> wrote:
> Nate Lowrie wrote:
> > Sorry, about the partial message. Accidentally hit send.
> > I have a couple of applications that I wish to have a setup.py file
> > for. The directory structure is like the following:
> > root
> > - setup.py
> > - App1
> > - App1.py
> > - foo.py
> > - bar.py
> > - App2
> > - App2.py
> > you get the idea. App1.py imports foo and bar. My setup.py file runs
> > just fine and I get executables for App1 and App2. I go to run App1
> > and I get the following error:
> > Traceback (most recent call last):
> > File "App1.py", line 35, in <module>
> > ImportError: No module named foo
> > line 35 corresponds to "import foo". I am pretty sure it has to do
> > with the fact that the setup.py is not in the same directory as App1.
> > Any suggestions on how to fix this?
> > Cheers,
> > Nate Lowrie
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> Yep that's why. When you import foo in App2 it can't see it from the
> subdirectory. Why go to all this trouble. Just put everything in a single
> Nothing much to be accomplished with all the subdirectories. You could do what
> you wanted if you put foo.py and bar.py into a module.
Ok, maybe I should have explained this better. The directory
structure of my applications is like the example that I gave. I used
a simplified structure to get the problem across better. However,
there are 6 applications in the structure. foo.py and bar.py are
specific only to App1. The other apps don't need them and they
wouldn't get any reuse if put into a module. There are at least 5 .py
files for every application. Putting them all in the same folder is
an option, but organizationally I would like to keep them in separate
I could do a separate setup.py for each of them. However, they are
all loosely linked by the common goal of managing a business. One app
is for billing, the other is for marketing, another for accounting,
etc. I wanted to compile them with the same .py file so that they
would share the same resources not take up as much space.
That said, it's not that App2 is importing foo and not finding it.
But rather, I specify the script file using os.path.join("App1",
"App1.py") and I think it only grabs App1.py from the App1 directory
but not any of the other .py files in that directory. So, I
understand I can throw everything into 1 directory or put the
supporting files into a module. However, is there a way to do this
without doing either of them? It seems like it is a simple thing that
I am missing...
Thanks for the help so far.