On Mar 20, 1:59 pm, "gtb" <[EMAIL PROTECTED]> wrote: > On Mar 20, 1:51 pm, [EMAIL PROTECTED] wrote: > > > > > On Mar 20, 1:31 pm, "gtb" <[EMAIL PROTECTED]> 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 -- http://mail.python.org/mailman/listinfo/python-list