From: Joern E. <Joe...@mi...> - 2001-07-23 12:45:07
|
> [Joern Eckhoff] > > >While working in a DOS-Box import works really fine. But writing a script > >which imports the same pakages throws an exception. > > It sounds like a embedding problem. Try to check the value of sys.path > at the beginning of your script. > > If you are doing the embedding take a look at this FAQ answer for how to > set up a usefull python.path. > > http://www.jython.org/cgi-bin/faqw.py?req=show&file=faq06.002.htp > > Otherwise you can always add entries to sys.path from within your > script. > > regards, > finn Hi again, thanks, finn, for the hint, but ... it doesn't work yet. I've read the site you've quoted above and the according site at jython.com. I've tried to find the registry file, but wasn't able to do so. Actually it isn't neccessary at all, right? I'm working on WinNT and a name .jython for a file isn't allowed (Message: You must type a filename). So I suggest it's the file called registry at c:\program files\jython as stated in the docs of jython (It took half a day to find the hint for that. It's placed _very_ unfavourable). Even after adding an own line specifying the path matching my system it doesn't work. This is what I've added to c:\program files\jython\registry: # this is how to specify the path at my computer. Joern python.path=c:\\program files\\jython;c:\\program files\\jython\\lib After that and adding the code to set the python.path within the script, too, I've started the AdventNet SimulationToolkit again. This message was written to the log-file of the SimulationToolkit: Traceback (innermost last): (no code object) at line 0 File "D:\AdventNet\simulator\mibs\_behavior_scripts_\script.py", line 1 Properties props = new Properties(); ^ SyntaxError: invalid syntax Exception while executing the Python Script But ... erm ... the registry-file is updated, so why can't I remove the code specifying the path in the script? Well, after removing the code the path could not be found, therefore string could not be imported. Environmet is set: PYTHONPATH=c:\program files\jython;c:\program files\jython\lib ... Path within script is set: Properties props = new Properties(); props.setProperty("python.path", "c:\Program Files\Jython;c:\Program Files\Jython\lib"); PythonInterpreter.initialize(System.getProperties(), props, new String[] {""}); ... and line to file registry has been added: # this is how to specify the path at my computer. Joern python.path=c:\\program files\\jython;c:\\program files\\jython\\lib So, what to do next, IOW: What am I doing wrong? It seems to me that the Properties could not be found, i.e. jython could not resolve the line Properties props = new Properties() - but how? TIA for any help Joern (At his wits end) |