JsonRpc client in python

I am trying to use StanfordParser through python, and I am using this implementation of it, which is basically a remote server that answers json requests from what I understand. They recommend the following implementation pattern for the client side after starting the server.

import jsonrpc
from simplejson import loads
server = jsonrpc.ServerProxy(jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=("127.0.0.1", 8080)))

result = loads(server.parse("Hello world.  It is so beautiful"))
print "Result", result

however, I have no experience using jsonrpc, and I just installed it with pip install json-rpc. This does not seem to work, because when I try to run the client sample, I get the following exception.

Traceback (most recent call last):
  File "/root/PycharmProjects/testingStanfordParser/parser.py", line 1, in <module>
    import jsonrpc
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/__init__.py", line 6, in <module>
    from .manager import JSONRPCResponseManager
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/manager.py", line 12, in <module>
    from .jsonrpc1 import JSONRPC10Response
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/jsonrpc1.py", line 3, in <module>
    from .base import JSONRPCBaseRequest, JSONRPCBaseResponse
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/base.py", line 1, in <module>
    from .utils import JSONSerializable
  File "/usr/local/lib/python2.7/dist-packages/jsonrpc/utils.py", line 31, in <module>
    class DatetimeDecimalEncoder(json.JSONEncoder):
AttributeError: 'module' object has no attribute 'JSONEncoder'
+4
source share

All Articles