Imports

gtb goodTweetieBird at hotmail.com
Tue Mar 20 22:22:33 CET 2007


On Mar 20, 2:25 pm, kyoso... at gmail.com wrote:
> On Mar 20, 1:59 pm, "gtb" <goodTweetieB... at hotmail.com> wrote:
>
>
>
> > On Mar 20, 1:51 pm, kyoso... at gmail.com wrote:
>
> > > On Mar 20, 1:31 pm, "gtb" <goodTweetieB... at hotmail.com> wrote:
>
> > > > I am working with a tool called maxQ that generates jython scripts.
> > > > The tool runs in
>
> > > > C:\maxq\bin.
>
> > > > Rather than clutter up bin I want to put the scripts and other .py
> > > > scripts in
>
> > > > c:\maxq\bin\testScripts.
>
> > > > When doing so the scripts need to import from
>
> > > > c:\maxq\jython, but can't find the modules.
>
> > > > I tried adding c:\maxq\jython to the environment variable pythonpath
> > > > but to no avail. Perhaps I missed it in Rossum's tutorial but is there
> > > > a std prgrammatic way to specify a module directory?
>
> > > > Could you, would you, recommend a text or another webpage for learning
> > > > more (much more) about python?
>
> > > > Thanx,
>
> > > > gtb
>
> > > I typically just import sys and then do a
> > > sys.path.append(directoryPath). This basically makes whatever modules
> > > in that path available at run time. If you need a beginners reference
> > > book, I recommend "Beginning Python" by Hetland. "Python Programming
> > > for the Absolute Beginner" by Dawson was a lot of fun, but he doesn't
> > > get into the internals of the language like Hetland does. Once you're
> > > a snake charmer too, you can "graduate" to the "Programming Python"
> > > book by Lutz.
>
> > > Mike
>
> > Something else going on then, does the directory path need to be the
> > full path or will it search sub-directories?
>
> > Traceback (most recent call last):
> >   File "C:\maxq-0.98\bin\testScripts\compactLogin.py", line 2, in
> > <module>
> >     from CompactTest import CompactTest
> >   File "c:\maxq-0.98\jython\CompactTest.py", line 2, in <module>
> >     from java.lang import *
> > ImportError: No module named java.lang
>
> > Thanks for the book recommendations.
>
> > gtb
>
> Usually, the sys.path.append will allow Python to search the
> subfolders too, but I have noticed that sometimes it doesn't if you
> use UNC paths. I don't use jython, so maybe there's another way to fix
> this that is more specific to that implementation of Python?
>
> Mike

Thanks for the sys.path.append info. Turns out maxq cranks thing up
with java ( I should have seen it). The sys.path.append does
everything it supposed to do.

gtb




More information about the Python-list mailing list