Solved

socket erroe when invoking python from java app

Posted on 2004-09-09
3
232 Views
Last Modified: 2010-04-16
hi everyone,

I seem to have a winsock error when I tried to invoke my python xml server from within my java application. I know the server works fine because I checked it independently, I also manually started the server and then call the functions from my java app the problem is when I tried to start the python server from within the app I get the following error

Traceback (most recent call last):

  File "C:/Python23/new folder/file.py", line 1307, in ?

    server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8080))

  File "C:\Python23\lib\SimpleXMLRPCServer.py", line 450, in __init__

    SocketServer.TCPServer.__init__(self, addr, requestHandler)

  File "C:\Python23\lib\SocketServer.py", line 329, in __init__

    self.socket_type)

  File "C:\Python23\lib\socket.py", line 154, in __init__

    _sock = _realsocket(family, type, proto)

socket.error: (10091, 'Network subsystem is unvailable')


Any idea on why this happens?

thanks
0
Comment
Question by:jom20
3 Comments
 
LVL 11

Accepted Solution

by:
cjjclifford earned 50 total points
ID: 12024989
Hi,

Its probably related to runtime environments in this case - when you run the python application from cmdline, and it works, have a look at the environment (particularly around Python related paths/variables, and shared library/DLL paths/variables (its likely that the socket library (winsock?) is a DLL that needs some environment set (I don't use windows, so I can't figure it out completely). The environment that the java program is invoked is not passed on in calls to Runtime.exec(), you have to use the Runtime.exec() method that allows setting environment (i.e. the one with 3 arguments).

Try the following:

list the environment from cmdline.
run the python program
if the program works, unset one of the environment variables.
keep trying till one the program fails for the same reason as it is in Java - this is what needs to be set!

Cheers,
C.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Less strange, but still introduction This introduction was added (1st August, 2011) to reflect some reactions.  Firstly, the term basics in the title of the article...  As any other word, it is a symbol with meaning attached to the word by some a…
Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question