Solved

socket erroe when invoking python from java app

Posted on 2004-09-09
3
234 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pthon mysql - how to count number of rows in a table 3 51
bitwise OR python 2.7 4 57
Is it true to say that Python is successor of Perl? 7 207
yara deployment 8 102
Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
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…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

685 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