2

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?

4

1 回答 1

0

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.)

于 2009-05-05T15:46:29.837 回答