I was playing with Jython a bit and found this problem (or at least,
something I'm doing wrong):
I'm trying to compile a python script that imports the curses module,
and I get an error 'ImportError: no module named _curses' error. I
copied the modules from my python-2.0 directory to jython/Lib and got
further, but still the error boils down to '_curses' not being found.
Any ideas?
Verbose errors:
at java.lang.Throwable.<init>(Throwable.java:84)
at java.lang.Exception.<init>(Exception.java:35)
at java.lang.RuntimeException.<init>(RuntimeException.java:39)
at org.python.core.PyException.<init>(PyException.java:44)
at org.python.core.PyException.<init>(PyException.java:56)
at org.python.core.Py.ImportError(Py.java:180)
at org.python.core.imp.load(imp.java:368)
at org.python.core.imp.load(imp.java:376)
at org.python.core.imp.importName(imp.java:447)
at org.python.core.imp.importName(imp.java:509)
at org.python.core.ImportFunction.load(__builtin__.java:967)
at org.python.core.ImportFunction.__call__(__builtin__.java:961)
at org.python.core.PyObject.__call__(PyObject.java:250)
at org.python.core.__builtin__.__import__(__builtin__.java:921)
at org.python.core.imp.importAll(imp.java:592)
at curses$py.f$0(__init__.py)
at curses$py.call_function(__init__.py)
at org.python.core.PyTableCode.call(PyTableCode.java:155)
at org.python.core.imp.createFromCode(imp.java:157)
at org.python.core.imp.createFromSource(imp.java:147)
at org.python.core.imp.loadFromPath(imp.java:316)
at org.python.core.imp.loadFromPath(imp.java:293)
at org.python.core.imp.loadFromPath(imp.java:252)
at org.python.core.imp.load(imp.java:357)
at org.python.core.imp.load(imp.java:376)
at org.python.core.imp.importName(imp.java:447)
at org.python.core.imp.importName(imp.java:509)
at org.python.core.ImportFunction.load(__builtin__.java:967)
at org.python.core.ImportFunction.__call__(__builtin__.java:961)
at org.python.core.PyObject.__call__(PyObject.java:250)
at org.python.core.__builtin__.__import__(__builtin__.java:921)
at org.python.core.imp.importOne(imp.java:518)
at ctest$_PyInner.main$3(ctest.java:129)
at ctest$_PyInner.call_function(ctest.java:62)
at org.python.core.PyTableCode.call(PyTableCode.java:155)
at org.python.core.imp.createFromCode(imp.java:157)
at org.python.core.Py.runMain(Py.java:798)
at ctest.main(ctest.java:170)
Traceback (innermost last):
File "/home/matt/src/cvs/python/curses/ctest.py", line 0, in main
File "/usr/local/jython/Lib/curses/__init__.py", line 15, in ?
ImportError: no module named _curses
Source code:
import curses, traceback
import os
# Globals
options=[]
breakstate=0
def getMenuItems():
if options == []:
(pstdin,pstdout)=os.popen2('cd /etc/profiler; ls net*')
for line in pstdout.readlines():
options[:]+=[line[0:-1]]
def mainMenu(stdscr):
# Frame the interface area at fixed VT100 size
getMenuItems()
width=10
if len(options) > 6:
width+=len(options)-6
global screen
screen = stdscr.subwin(width, 70, 0, 0)
screen.box()
screen.hline(2, 1, curses.ACS_HLINE, 68)
screen.addstr(1,2,"Please choose the profile you wish to load:")
n=1
for option in options:
screen.addstr(2+n,5,str(n) + ". " + option)
n=n+1
screen.addstr(width-2,2,"Which Profile? (1-"+str(n-1) + ") ")
screen.refresh()
# Define the topbar menus
# file_menu = ("File", "file_func()")
#proxy_menu = ("Proxy Mode", "proxy_func()")
#doit_menu = ("Do It!", "doit_func()")
#help_menu = ("Help", "help_func()")
#exit_menu = ("Exit", "EXIT")
# Add the topbar menus to screen object
# topbar_menu((file_menu, proxy_menu, doit_menu,
# help_menu, exit_menu))
# Enter the topbar menu loop
# while topbar_key_handler():
# draw_dict()
if __name__=='__main__':
try:
# Initialize curses
stdscr=curses.initscr()
# Turn off echoing of keys, and enter cbreak mode,
# where no buffering is performed on keyboard input
curses.noecho()
curses.cbreak()
# In keypad mode, escape sequences for special keys
# (like the cursor keys) will be interpreted and
# a special value like curses.KEY_LEFT will be returned
stdscr.keypad(1)
mainMenu(stdscr) # Enter the main loop
# while breakstate == 0:
# c=screen.getch()
# if c == '
# Set everything back to normal
stdscr.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin() # Terminate curses
except:
# In event of error, restore terminal to sane state.
stdscr.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
traceback.print_exc() # Print the exception
|