8

I looked through the other posts and bug reports and couldn't figure out what's causing this. I'm using Jython 2.5.1, in a Java project in Eclipse (Ubuntu 8.10). It has been added to the project as a standalone .jar file (I just replaced the old Jython 2.1 jar with this one).

I'm running a script that uses the threading.py class. At some point the statement "import os" is evaluated from linecache.py and I get this error, which I can't seem to figure out how to fix:

'Execution failed.  Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File "../lib/python/threading.py", line 6, in <module>
 import traceback
 File "../lib/python/traceback.py", line 3, in <module>
 import linecache
 File "../lib/python/linecache.py", line 9, in <module>
 import os
 ImportError: No module named os'
Leonidas
  • 2,110
  • 4
  • 20
  • 31

3 Answers3

6

What do you mean with "the jar that comes with the 2.5 download"? Did you extract the contents and use jython.jar or did you run the installer? If you just extracted and didn't run the installer your jython.jar will miss the whole LIB folder.

Can you check if jython.jar contains a LIB folder? (e.g. open jython.jar with 7z or WinZip).

Or try copying the LIB folder in the same folder where jython.jar resides.


Did you try setting these properties. Jython Registry. e.g. via -Dpython.home in the eclipse run configuration.

python.cachedir
python.path
python.home

How is the jar named? If similar to jython-complete.jar try renaming it to jython.jar

jitter
  • 53,475
  • 11
  • 111
  • 124
  • I'm not sure how to do that. Do I need to do it from within Eclipse? The jar is named jython.jar. I just used the jar that comes with the 2.5 download. – Leonidas Oct 28 '09 at 19:10
  • Expanded answer. Check upper half – jitter Oct 28 '09 at 19:23
  • I just extracted and didn't run the installer. Just ran the installer but there still isn't a LIB folder in the jython.jar. – Leonidas Oct 28 '09 at 19:56
  • 1
    Did you use the "standalone" option on the installer? – jitter Oct 28 '09 at 20:19
  • Nope. I used it just now and the error I'm getting is now: File "/home/XXXXX/XXX/eclipseproject/build/dist/lib/jython.jar/Lib/os.py", line 132, in ImportError: cannot import name curdir' – Leonidas Oct 28 '09 at 20:35
  • Any other possible ideas? This problemo is still lurking – Leonidas Oct 30 '09 at 20:09
  • Last suggestion would be to extract os.py from the jython.jar (standalone) edit it around line 132 to print out os.path and sys.path. And repackage the modified os.py into the jar – jitter Oct 31 '09 at 09:34
1

If you are getting maven, using the dependency jython-standalone instead of jython may help (at least it did for me in a maven project with jython-standalone-2.5.3)

Andre Holzner
  • 18,333
  • 6
  • 54
  • 63
1

Something is wrong at a very deep level, but it's probably easy to fix. You are seeing an error that happens while trying to report some other error.

Probably you have your PYTHONPATH misconfigured. I don't know the details of Jython or Eclipse running Jython, but it looks like you have no standard library available to you.

Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662