I’m working with a product that has a built-in Jython 2.2 instance. It comes with none of the Python standard libraries. When I run this instance of Jython, the default path is
['./run/Jython/Lib', './run/Jython', '__classpath__']
I added all of the .py module files from Python 2.2 to the ./run/Jython/Lib directory, and I am able to import them. But I want to use urllib2 and I get this error:
Traceback (innermost last):
File "<string>", line 2, in ?
File "./run/Jython/Lib/urllib2.py", line 90, in ?
File "./run/Jython/Lib/socket.py", line 41, in ?
ImportError: no module named _socket
As far as I can tell, the _socket module is part of the Python lib-dynload libraries (_socket.so). Can Jython use this file? I tried putting it in my path, but it had no effect.
A Google search seems to tell me that others are able to use urllib and urllib2 with Jython 2.2, but I’m stuck I have tried module libraries from older and newer versions of Python as well.
Thanks!
Andy,
I got a clean Jython 2.2.1 install and ran the following script successfully.
I went back and checked the Meandre infrastructure code base. I have found that a minor modification was introduced into the path of the embedded Jython. However, that is not the main problem. The main issue is that I just realized that the Jython’s system modules are missing on the Meandre distribution bundles.
You could fix it by manually copying the contents on the
to
and restart the server instance. Now the default modules should be available to the components of the infrastructure.
Just let me know if that gets you going and I will work on getting that fixed soon.