From: Kent J. <ken...@sk...> - 2003-10-13 20:29:23
|
I am having a problem importing Java packages in compiled jython code. For example I have this program that uses log4j: ### test.py from org.apache.log4j import BasicConfigurator, Logger __log = Logger.getLogger('DocWindow') if __name__ == '__main__': BasicConfigurator.configure() __log.info('this is a test') If I run this with the command line >java -cp "../lib/jython-2.1.jar;../lib/log4j-1.2.8-partial.jar" org.python.util.jython test.py I get the expected output 0 [main] INFO DocWindow - this is a test I then compile test.py to test.jar using >jythonc --deep --jar test.jar test.py If I then run from the jar I get an ImportError: >java -cp "test.jar;../lib/jython-2.1.jar;../lib/log4j-1.2.8-partial.jar" test Exception in thread "main" Traceback (innermost last): File "D:\Projects\Meccano\editor\test.py", line 0, in main ImportError: No module named log4j I have tried also compiling with --core and --all but I get an error during the build: Building archive: test.jar Tracking java dependencies: Traceback (innermost last): File "E:\jython-2.1\Tools\jythonc\jythonc.py", line 5, in ? File "E:\jython-2.1\Tools\jythonc\main.py", line 301, in main File "E:\jython-2.1\Tools\jythonc\main.py", line 294, in writeResults File "E:\jython-2.1\Tools\jythonc\jar.py", line 98, in dump File "E:\jython-2.1\Tools\jythonc\jar.py", line 92, in dumpFiles File "E:\jython-2.1\Tools\jythonc\jar.py", line 111, in addPackage java.util.zip.ZipException: duplicate entry: org/python/core/FixedFileWrapper.class at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:163) ...etc. I tried with both jython 2.1 and 2.2a0. With 2.2a0 the module compiles with --core but the import still fails. How can I get this import to work? Thanks! Kent |