Using JYTHON inside ANT : access os module -> "ImportError: no module named javaos"
CarlosRivera
CarlosRivera at badnamefornospam.to
Thu Oct 7 01:41:28 EDT 2004
I ran into that one as well. I think that you have to have the PYTHON
path or classpath properly setup to reference them. I did not really
need anything from python, so I just used java routines for everything
as I was generating a manifest file.
Tip: Due to the forced indent from python, I moved the script to a
separate file. This way the code can look like a normal jython/python
script.
eric_bellard wrote:
> Using JYTHO inside ANT : access os module
>
> Hi,
>
> I like to use JYTHON inside ANT task.
>
> I'm using:
> - WSAD 5.1.1
> - jython.jar inside WTE5.1
> - bsf.jar inside WTE5.1
>
> I've referenced jython.jar and bsf.jar into the ant classpath
> (Windows>Preferences>Ant>Runtime>Classpath)
>
> Here's a working script:
>
> <project name="helloWorld" default="jython-hello-world" basedir=".">
>
> <property name="test.path.dir" location="D:/tmp/jyton"/>
> <target name="jython-hello-world">
> <script language="jython">
> <![CDATA[
> import sys
>
>
> print 'Hello Jytho World'
> path = project.getProperty("test.path.dir")
> print path
>
> ]]>
> </script>
> </target>
> </project>
>
>
> The problem is when I want to access to the ptyhon 'os' module.
> The following target don't work:
> <target name="jython-hello-world2">
> <script language="jython">
> <![CDATA[
> import sys, os
>
>
> print 'Hello Jytho World'
> path = project.getProperty("test.path.dir")
> print path
> os.listdir(path)
> ]]>
> </script>
> </target>
>
>
> The returned error is:
>
> jython-hello-world:
> [script] Hello Jytho World
> [script] D:\tmp\jyton
> [script] BUILD FAILED:
> file:D:/cc_views/dinb_comp_java_jraf_v2_0_act_E391485/dinb_comp_java_jraf/livraison/jython/build.xml:63:
> Traceback (innermost last):
> File "<string>", line 8, in ?
> ImportError: no module named javaos
>
>
> Does someone has any clue?
>
> Thanks by advance.
>
> Eric
More information about the Python-list
mailing list