views:

102

answers:

1

I am trying to imported a java class from an external lib in jyhon and it does not work. An example

package run;
    import import.Imported;
    Class Run()
    {
        public static void main(String[] args){
                 pi = new PythonInterpreter(null);
     pi.execfile('script.py');
            }
    }
    //this is an external libary
    package import;
    Class Imported()
    {
         //some stuff;
    }

   //py script
   from import import Imported //this line throws an error Module not found
   #do some stuff

The strangest thing is that it runs when it is compiled in Eclipse, but does not from command line. Any help?

A: 

Sounds like your classpath is probably set incorrectly at runtime. The easiest solution is typically just to add the directory or jar file containing 'import' to sys.path.

(Also, naming your packages 'import' is just asking for trouble.)

Nicholas Riley
naming was for example only :). Thanks.Apparently when I run the shell script it works, but when I do the same from commandline it does not. Anyway, solved.
Ilija