From: Matthew <coc...@sb...> - 2005-02-07 07:10:01
|
Hello, I was hoping to get a bit of guidance. I've done quite a bit Java programming but not so much Python, so I suspect my problem is rather simple one, although it doesn't seem that way to me. I've downloaded the DocUtils for python and successfully run the examples on my machine, so I know they're running and Python is OK. (I'm assuming that "regulars" around here are familiar enough with Docutils, although I could be wrong) I've successfully compiled a HelloWorld python script using jythonc and then run it using java, so I know that in order to do that I had to have my classpath set up correctly for java, point to the jython.jar file, etc. When I run jythonc on any of the docutils examples, however, things don't work so smoothly. In the docutils/tools folder, I've tried to compile the rst2html.py with jythonc and it compiles just fine. I've tried using --all and/or --deep options and it compiles fine anyway you do it. For reference, here's that script and its output ##################################################################### """ A minimal front end to the Docutils Publisher, producing HTML. """ try: import locale locale.setlocale(locale.LC_ALL, '') except: pass from docutils.core import publish_cmdline, default_description description = ('Generates (X)HTML documents from standalone reStructuredText ' 'sources. ' + default_description) publish_cmdline(writer_name='html', description=description) ################################################################### compilation stuff: ################################################################### processing rst2html Required packages: docutils Creating adapters: Creating .java files: rst2html module Compiling .java to .class... Compiling with args: ['/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/bin/ javac', '-classpath', '/Users/matthew/Library/jython-2.1/jython.jar:/Users/matthew/Library/ jython-2.1/:/Users/matthew/Library/jython-2.1/:.:/Users/matthew/ Library/jython-2.1/:.:/Users/matthew/Library/jython-2.1/jython.jar:./ jpywork::/Users/matthew/Library/jython-2.1/Tools/jythonc:/Users/ matthew/Library/jython-2.1/docutils/docutils/.:/Users/matthew/Library/ jython-2.1/Lib', './jpywork/rst2html.java'] 0 /Users/matthew/Library/jython-2.1/org/python/core/Py.java:989: warning: as of release 1.4, assert is a keyword, and may not be used as an identifier public static void assert(PyObject test, PyObject message) { ^ /Users/matthew/Library/jython-2.1/org/python/core/Py.java:995: warning: as of release 1.4, assert is a keyword, and may not be used as an identifier public static void assert(PyObject test) { ^ /Users/matthew/Library/jython-2.1/org/python/core/Py.java:996: warning: as of release 1.4, assert is a keyword, and may not be used as an identifier assert(test, Py.None); ^ Note: Some input files use or override a deprecated API. Note: Recompile with -deprecation for details. 3 warnings ######################################################################## So when I try to run the rst2html file in the jpywork folder, I get this error: Exception in thread "main" Traceback (innermost last): File "/Users/matthew/Library/jython-2.1/docutils/docutils/rst2html.py", line 0, in main ImportError: No module named core My CLASSPATH is set correctly as far as I know: CLASSPATH=/Users/matthew/Library/jython-2.1/:.:/Users/matthew/Library/ jython-2.1/jython.jar and my PYTHONPATH (not sure how this fits in, or if it matters) is set correctly too, I believe: PYTHONPATH=/sw/lib/python2.3/site-packages/docutils (tried not using the final "docutils" prefix as well as well as explicitly pointing to "docutils/core") but still I get that error. As I understand, it's telling me that it can't find the "core" module that has been indicated to be in the docutils folder, that's I belive to be in the PYTHONPATH?!? This is the line in the java relic left behind that is the culprit, which causes the runtime problem: imp_accu = org.python.core.imp.importFrom("docutils.core", new String[] {"publish_cmdline", "default_description"}, frame); Again, the file rst2html.py runs fine from the command line using python alone, so I'm expecting that this is a simple newbie issue relating to the Python runtime that I'm just not getting? Thanks for any help. Matthew |
From: Matthew <coc...@sb...> - 2005-02-07 07:12:52
|
And sorry, in case this is relevant to the problem: java version "1.4.2_05" Python 2.3.3 (#1, Mar 12 2004, 23:21:41) (Fink) Jython 2.1 Matthew On Feb 7, 2005, at 2:09 AM, Matthew wrote: > Hello, > > I was hoping to get a bit of guidance. I've done quite a bit Java > programming but not so much Python, so I suspect my problem is rather > simple one, although it doesn't seem that way to me. > > I've downloaded the DocUtils for python and successfully run the > examples on my machine, so I know they're running and Python is OK. > (I'm assuming that "regulars" around here are familiar enough with > Docutils, although I could be wrong) > > I've successfully compiled a HelloWorld python script using jythonc > and then run it using java, so I know that in order to do that I had > to have my classpath set up correctly for java, point to the > jython.jar file, etc. > > When I run jythonc on any of the docutils examples, however, things > don't work so smoothly. In the docutils/tools folder, I've tried to > compile the rst2html.py with jythonc and it compiles just fine. I've > tried using --all and/or --deep options and it compiles fine anyway > you do it. For reference, here's that script and its output > > ##################################################################### > """ > A minimal front end to the Docutils Publisher, producing HTML. > """ > > try: > import locale > locale.setlocale(locale.LC_ALL, '') > except: > pass > > from docutils.core import publish_cmdline, default_description > > > description = ('Generates (X)HTML documents from standalone > reStructuredText ' > 'sources. ' + default_description) > > publish_cmdline(writer_name='html', description=description) > > ################################################################### > compilation stuff: > ################################################################### > processing rst2html > > Required packages: > docutils > > Creating adapters: > > Creating .java files: > rst2html module > > Compiling .java to .class... > Compiling with args: > ['/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/bin/ > javac', '-classpath', > '/Users/matthew/Library/jython-2.1/jython.jar:/Users/matthew/Library/ > jython-2.1/:/Users/matthew/Library/jython-2.1/:.:/Users/matthew/ > Library/jython-2.1/:.:/Users/matthew/Library/jython-2.1/jython.jar:./ > jpywork::/Users/matthew/Library/jython-2.1/Tools/jythonc:/Users/ > matthew/Library/jython-2.1/docutils/docutils/.:/Users/matthew/Library/ > jython-2.1/Lib', './jpywork/rst2html.java'] > 0 /Users/matthew/Library/jython-2.1/org/python/core/Py.java:989: > warning: as of release 1.4, assert is a keyword, and may not be used > as an identifier > public static void assert(PyObject test, PyObject message) { > ^ > /Users/matthew/Library/jython-2.1/org/python/core/Py.java:995: > warning: as of release 1.4, assert is a keyword, and may not be used > as an identifier > public static void assert(PyObject test) { > ^ > /Users/matthew/Library/jython-2.1/org/python/core/Py.java:996: > warning: as of release 1.4, assert is a keyword, and may not be used > as an identifier > assert(test, Py.None); > ^ > Note: Some input files use or override a deprecated API. > Note: Recompile with -deprecation for details. > 3 warnings > ####################################################################### > # > > So when I try to run the rst2html file in the jpywork folder, I get > this error: > > Exception in thread "main" Traceback (innermost last): > File > "/Users/matthew/Library/jython-2.1/docutils/docutils/rst2html.py", > line 0, in main > ImportError: No module named core > > > My CLASSPATH is set correctly as far as I know: > > CLASSPATH=/Users/matthew/Library/jython-2.1/:.:/Users/matthew/Library/ > jython-2.1/jython.jar > > and my PYTHONPATH (not sure how this fits in, or if it matters) is set > correctly too, I believe: > > PYTHONPATH=/sw/lib/python2.3/site-packages/docutils (tried not using > the final "docutils" prefix as well as well as explicitly pointing to > "docutils/core") > > but still I get that error. As I understand, it's telling me that it > can't find the "core" module that has been indicated to be in the > docutils folder, that's I belive to be in the PYTHONPATH?!? This is > the line in the java relic left behind that is the culprit, which > causes the runtime problem: > > imp_accu = org.python.core.imp.importFrom("docutils.core", new > String[] {"publish_cmdline", "default_description"}, frame); > > Again, the file rst2html.py runs fine from the command line using > python alone, so I'm expecting that this is a simple newbie issue > relating to the Python runtime that I'm just not getting? > > Thanks for any help. > > Matthew > |
From: Kent J. <ke...@td...> - 2005-02-07 10:44:09
|
Matthew wrote: > Hello, > > I was hoping to get a bit of guidance. I've done quite a bit Java > programming but not so much Python, so I suspect my problem is rather > simple one, although it doesn't seem that way to me. > > I've downloaded the DocUtils for python and successfully run the > examples on my machine, so I know they're running and Python is OK. Have you tried running DocUtils using *jython*? You can do this without compiling DocUtils, just run from the .py files. I tried this with jython 2.1 and docutils-0.3.5 and find that docutils uses optparse which is not part of jython. Jython implements Python 2.1 so any modules that need features from Python >= 2.2 won't work with Jython. Kent |
From: Matthew <coc...@sb...> - 2005-02-07 14:10:16
|
Now, that you mention it ,the docutils README does say Python 2.2 or later [1]_ is required; Python 2.2.2 or later is recommended. so that must be it. FYI, when i try to run "%jython rst2html.py" I get the same error noting that package "core" cannot be found. Still not entirely sure how that fits into things. I'm really just looking to be able to use some of the most basic docutils capabilities from Java, so as time permits, I'll see if I can't find out which older versions of docutils will work with python 2.1 or lower and get back with everyone, just in case anyone else wants to do this before jython 2.2 is out--which should be compatible with python 2.1, I take it--which there is not tentative release time yet? I noticed there's an alpha package, but am (obviously) new to this whole community. Thanks again for helping me to recognize what's going on here. Matthew On Feb 7, 2005, at 5:43 AM, Kent Johnson wrote: > Matthew wrote: >> Hello, >> I was hoping to get a bit of guidance. I've done quite a bit Java >> programming but not so much Python, so I suspect my problem is rather >> simple one, although it doesn't seem that way to me. >> I've downloaded the DocUtils for python and successfully run the >> examples on my machine, so I know they're running and Python is OK. > > Have you tried running DocUtils using *jython*? You can do this > without compiling DocUtils, just run from the .py files. > > I tried this with jython 2.1 and docutils-0.3.5 and find that docutils > uses optparse which is not part of jython. > > Jython implements Python 2.1 so any modules that need features from > Python >= 2.2 won't work with Jython. > > Kent > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting > Tool for open source databases. Create drag-&-drop reports. Save time > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. > Download a FREE copy at http://www.intelliview.com/go/osdn_nl > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Kent J. <ke...@td...> - 2005-02-07 14:32:34
|
Matthew wrote: > Now, that you mention it ,the docutils README does say > > Python 2.2 or later [1]_ is required; Python 2.2.2 or later is > recommended. > > so that must be it. FYI, when i try to run "%jython rst2html.py" I get > the same error noting that package "core" cannot be found. Still not > entirely sure how that fits into things. Unfortunately import errors don't always give the clearest error messages. What is happening here is core imports frontend frontend import optparse optparse is not found generating an import error Jython reports it as an error importing core which doesn't give much of an idea what the problem is. With import errors it's a good idea to drill down a bit until you find the real problem. What I did was to try C:\Downloads\Python\docutils-0.3.5>jython Jython 2.1 on java1.4.2_06 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import docutils.core Traceback (innermost last): File "<console>", line 1, in ? File "C:\Downloads\Python\docutils-0.3.5\docutils\core.py", line 22, in ? ImportError: cannot import name frontend >>> ^Z Restart Jython to get a clean slate and try C:\Downloads\Python\docutils-0.3.5>jython Jython 2.1 on java1.4.2_06 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import docutils.frontend Traceback (innermost last): File "<console>", line 1, in ? File "C:\Downloads\Python\docutils-0.3.5\docutils\frontend.py", line 39, in ? ImportError: no module named optparse >>> and that is down to the real problem. Kent |