kRPC: Control the game using C#, C++, Java, Lua, Python...

kRPC: Control the game using C#, C++, Java, Lua, Python...

7.8k Downloads

"TypeError: __new__() got an unexpected keyword argument 'serialized_options'

cknowles2112 opened this issue · 7 comments

commented
commented

On Mac With plugin and library 0.4.8 - on "import krpc" receive that error, along with the following output:

Python 3.6.5 (default, May 15 2018, 22:12:43)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import krpc
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/krpc/init.py", line 1, in
from krpc.connection import Connection
File "/usr/local/lib/python3.6/site-packages/krpc/connection.py", line 3, in
from krpc.encoder import Encoder
File "/usr/local/lib/python3.6/site-packages/krpc/encoder.py", line 8, in
import krpc.schema.KRPC_pb2 as KRPC
File "/usr/local/lib/python3.6/site-packages/krpc/schema/KRPC_pb2.py", line 22, in
serialized_pb=_b('\n\x13protobuf/krpc.proto\x12\x0bkrpc.schema"\x93\x01\n\x11\x43onnectionRequest\x12\x31\n\x04type\x18\x01 \x01(\x0e\x32#.krpc.schema.ConnectionRequest.Type\x12\x13\n\x0b\x63lient_name\x18\x02 \x01(\t\x12\x19\n\x11\x63lient_identifier\x18\x03 \x01(\x0c"\x1b\n\x04Type\x12\x07\n\x03RPC\x10\x00\x12\n\n\x06STREAM\x10\x01"\xbe\x01\n\x12\x43onnectionResponse\x12\x36\n\x06status\x18\x01 \x01(\x0e\x32&.krpc.schema.ConnectionResponse.Status\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x19\n\x11\x63lient_identifier\x18\x03 \x01(\x0c"D\n\x06Status\x12\x06\n\x02OK\x10\x00\x12\x15\n\x11MALFORMED_MESSAGE\x10\x01\x12\x0b\n\x07TIMEOUT\x10\x02\x12\x0e\n\nWRONG_TYPE\x10\x03"4\n\x07Request\x12)\n\x05\x63\x61lls\x18\x01 \x03(\x0b\x32\x1a.krpc.schema.ProcedureCall"\x87\x01\n\rProcedureCall\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x11\n\tprocedure\x18\x02 \x01(\t\x12\x12\n\nservice_id\x18\x04 \x01(\r\x12\x14\n\x0cprocedure_id\x18\x05 \x01(\r\x12(\n\targuments\x18\x03 \x03(\x0b\x32\x15.krpc.schema.Argument"+\n\x08\x41rgument\x12\x10\n\x08position\x18\x01 \x01(\r\x12\r\n\x05value\x18\x02 \x01(\x0c"\\n\x08Response\x12!\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x12.krpc.schema.Error\x12-\n\x07results\x18\x02 \x03(\x0b\x32\x1c.krpc.schema.ProcedureResult"C\n\x0fProcedureResult\x12!\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x12.krpc.schema.Error\x12\r\n\x05value\x18\x02 \x01(\x0c"P\n\x05\x45rror\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12\x13\n\x0bstack_trace\x18\x04 \x01(\t":\n\x0cStreamUpdate\x12*\n\x07results\x18\x01 \x03(\x0b\x32\x19.krpc.schema.StreamResult"H\n\x0cStreamResult\x12\n\n\x02id\x18\x01 \x01(\x04\x12,\n\x06result\x18\x02 \x01(\x0b\x32\x1c.krpc.schema.ProcedureResult"2\n\x08Services\x12&\n\x08services\x18\x01 \x03(\x0b\x32\x14.krpc.schema.Service"\xdb\x01\n\x07Service\x12\x0c\n\x04name\x18\x01 \x01(\t\x12*\n\nprocedures\x18\x02 \x03(\x0b\x32\x16.krpc.schema.Procedure\x12#\n\x07\x63lasses\x18\x03 \x03(\x0b\x32\x12.krpc.schema.Class\x12.\n\x0c\x65numerations\x18\x04 \x03(\x0b\x32\x18.krpc.schema.Enumeration\x12*\n\nexceptions\x18\x05 \x03(\x0b\x32\x16.krpc.schema.Exception\x12\x15\n\rdocumentation\x18\x06 \x01(\t"\xcd\x02\n\tProcedure\x12\x0c\n\x04name\x18\x01 \x01(\t\x12*\n\nparameters\x18\x02 \x03(\x0b\x32\x16.krpc.schema.Parameter\x12&\n\x0breturn_type\x18\x03 \x01(\x0b\x32\x11.krpc.schema.Type\x12\x1a\n\x12return_is_nullable\x18\x04 \x01(\x08\x12\x35\n\x0bgame_scenes\x18\x06 \x03(\x0e\x32 .krpc.schema.Procedure.GameScene\x12\x15\n\rdocumentation\x18\x05 \x01(\t"t\n\tGameScene\x12\x10\n\x0cSPACE_CENTER\x10\x00\x12\n\n\x06\x46LIGHT\x10\x01\x12\x14\n\x10TRACKING_STATION\x10\x02\x12\x0e\n\nEDITOR_VAB\x10\x03\x12\x0e\n\nEDITOR_SPH\x10\x04\x12\x13\n\x0fMISSION_BUILDER\x10\x05"Q\n\tParameter\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1f\n\x04type\x18\x02 \x01(\x0b\x32\x11.krpc.schema.Type\x12\x15\n\rdefault_value\x18\x03 \x01(\x0c",\n\x05\x43lass\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x15\n\rdocumentation\x18\x02 \x01(\t"a\n\x0b\x45numeration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12-\n\x06values\x18\x02 \x03(\x0b\x32\x1d.krpc.schema.EnumerationValue\x12\x15\n\rdocumentation\x18\x03 \x01(\t"F\n\x10\x45numerationValue\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\x12\x15\n\rdocumentation\x18\x03 \x01(\t"0\n\tException\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x15\n\rdocumentation\x18\x02 \x01(\t"\x88\x03\n\x04Type\x12(\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x1a.krpc.schema.Type.TypeCode\x12\x0f\n\x07service\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12 \n\x05types\x18\x04 \x03(\x0b\x32\x11.krpc.schema.Type"\x94\x02\n\x08TypeCode\x12\x08\n\x04NONE\x10\x00\x12\n\n\x06\x44OUBLE\x10\x01\x12\t\n\x05\x46LOAT\x10\x02\x12\n\n\x06SINT32\x10\x03\x12\n\n\x06SINT64\x10\x04\x12\n\n\x06UINT32\x10\x05\x12\n\n\x06UINT64\x10\x06\x12\x08\n\x04\x42OOL\x10\x07\x12\n\n\x06STRING\x10\x08\x12\t\n\x05\x42YTES\x10\t\x12\t\n\x05\x43LASS\x10\x64\x12\x0f\n\x0b\x45NUMERATION\x10\x65\x12\n\n\x05\x45VENT\x10\xc8\x01\x12\x13\n\x0ePROCEDURE_CALL\x10\xc9\x01\x12\x0b\n\x06STREAM\x10\xca\x01\x12\x0b\n\x06STATUS\x10\xcb\x01\x12\r\n\x08SERVICES\x10\xcc\x01\x12\n\n\x05TUPLE\x10\xac\x02\x12\t\n\x04LIST\x10\xad\x02\x12\x08\n\x03SET\x10\xae\x02\x12\x0f\n\nDICTIONARY\x10\xaf\x02"\x16\n\x05Tuple\x12\r\n\x05items\x18\x01 \x03(\x0c"\x15\n\x04List\x12\r\n\x05items\x18\x01 \x03(\x0c"\x14\n\x03Set\x12\r\n\x05items\x18\x01 \x03(\x0c";\n\nDictionary\x12-\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x1c.krpc.schema.DictionaryEntry"-\n\x0f\x44ictionaryEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\r\n\x05value\x18\x02 \x01(\x0c"\x14\n\x06Stream\x12\n\n\x02id\x18\x01 \x01(\x04",\n\x05\x45vent\x12#\n\x06stream\x18\x01 \x01(\x0b\x32\x13.krpc.schema.Stream"\xf4\x03\n\x06Status\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x12\n\nbytes_read\x18\x02 \x01(\x04\x12\x15\n\rbytes_written\x18\x03 \x01(\x04\x12\x17\n\x0f\x62ytes_read_rate\x18\x04 \x01(\x02\x12\x1a\n\x12\x62ytes_written_rate\x18\x05 \x01(\x02\x12\x15\n\rrpcs_executed\x18\x06 \x01(\x04\x12\x10\n\x08rpc_rate\x18\x07 \x01(\x02\x12\x1a\n\x12one_rpc_per_update\x18\x08 \x01(\x08\x12\x1b\n\x13max_time_per_update\x18\t \x01(\r\x12\x1d\n\x15\x61\x64\x61ptive_rate_control\x18\n \x01(\x08\x12\x15\n\rblocking_recv\x18\x0b \x01(\x08\x12\x14\n\x0crecv_timeout\x18\x0c \x01(\r\x12\x1b\n\x13time_per_rpc_update\x18\r \x01(\x02\x12 \n\x18poll_time_per_rpc_update\x18\x0e \x01(\x02\x12 \n\x18\x65xec_time_per_rpc_update\x18\x0f \x01(\x02\x12\x13\n\x0bstream_rpcs\x18\x10 \x01(\r\x12\x1c\n\x14stream_rpcs_executed\x18\x11 \x01(\x04\x12\x17\n\x0fstream_rpc_rate\x18\x12 \x01(\x02\x12\x1e\n\x16time_per_stream_update\x18\x13 \x01(\x02"w\n\x12MultiplexedRequest\x12:\n\x12\x63onnection_request\x18\x01 \x01(\x0b\x32\x1e.krpc.schema.ConnectionRequest\x12%\n\x07request\x18\x02 \x01(\x0b\x32\x14.krpc.schema.Request"p\n\x13MultiplexedResponse\x12'\n\x08response\x18\x01 \x01(\x0b\x32\x15.krpc.schema.Response\x12\x30\n\rstream_update\x18\x02 \x01(\x0b\x32\x19.krpc.schema.StreamUpdateB-\n\x0bkrpc.schemaB\x04KRPC\xa2\x02\x04KRPC\xaa\x02\x10KRPC.Schema.KRPCb\x06proto3')
TypeError: new() got an unexpected keyword argument 'serialized_options'

Reverting to 0.4.7 and it works fine.

commented

Probably a protobuf compatibility issue. kRPC v0.4.8 was built against protobuf 3.6.1. kRPC v0.4.7 was built against protobuf 3.5.1. Maybe try upgrading your protobuf and see if that fixes the issue?

commented
commented

This happens to me too.
In my case protobuf:3.5.2.post1 was installed and pip install -U protobuf just solved the issue.

How about to update setup.py to specify required protobuf version a bit more detail?
I made the PR #510.

The change in protobuf seems to be introduced in 3.6.0 at this commit, I believe protobuf>=3.6 would be detailed enough.

commented

i had the same problem, but after updating protobuf to 3.6.1 there was a new error on importing:

File "C:/Users/Flo/Python/ksp/testhopper.py", line 8, in
import krpc

File "C:\ProgramData\Anaconda3\lib\site-packages\krpc_init_.py", line 1, in
from krpc.connection import Connection

File "C:\ProgramData\Anaconda3\lib\site-packages\krpc\connection.py", line 3, in
from krpc.encoder import Encoder

File "C:\ProgramData\Anaconda3\lib\site-packages\krpc\encoder.py", line 8, in
import krpc.schema.KRPC_pb2 as KRPC

File "C:\ProgramData\Anaconda3\lib\site-packages\krpc\schema\KRPC_pb2.py", line 22, in
serialized_pb=_b('\n\x13protobuf/krpc.proto\x12\x0bkrpc.schema"\x93\x01\n\x11\x43onnectionRequest\x12\x31\n\x04type\x18\x01 \x01(\x0e\x32#.krpc.schema.ConnectionRequest.Type\x12\x13\n\x0b\x63lient_name\x18\x02 \x01(\t\x12\x19\n\x11\x63lient_identifier\x18\x03 \x01(\x0c"\x1b\n\x04Type\x12\x07\n\x03RPC\x10\x00\x12\n\n\x06STREAM\x10\x01"\xbe\x01\n\x12\x43onnectionResponse\x12\x36\n\x06status\x18\x01 \x01(\x0e\x32&.krpc.schema.ConnectionResponse.Status\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x19\n\x11\x63lient_identifier\x18\x03 \x01(\x0c"D\n\x06Status\x12\x06\n\x02OK\x10\x00\x12\x15\n\x11MALFORMED_MESSAGE\x10\x01\x12\x0b\n\x07TIMEOUT\x10\x02\x12\x0e\n\nWRONG_TYPE\x10\x03"4\n\x07Request\x12)\n\x05\x63\x61lls\x18\x01 \x03(\x0b\x32\x1a.krpc.schema.ProcedureCall"\x87\x01\n\rProcedureCall\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x11\n\tprocedure\x18\x02 \x01(\t\x12\x12\n\nservice_id\x18\x04 \x01(\r\x12\x14\n\x0cprocedure_id\x18\x05 \x01(\r\x12(\n\targuments\x18\x03 \x03(\x0b\x32\x15.krpc.schema.Argument"+\n\x08\x41rgument\x12\x10\n\x08position\x18\x01 \x01(\r\x12\r\n\x05value\x18\x02 \x01(\x0c"\\n\x08Response\x12!\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x12.krpc.schema.Error\x12-\n\x07results\x18\x02 \x03(\x0b\x32\x1c.krpc.schema.ProcedureResult"C\n\x0fProcedureResult\x12!\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x12.krpc.schema.Error\x12\r\n\x05value\x18\x02 \x01(\x0c"P\n\x05\x45rror\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12\x13\n\x0bstack_trace\x18\x04 \x01(\t":\n\x0cStreamUpdate\x12*\n\x07results\x18\x01 \x03(\x0b\x32\x19.krpc.schema.StreamResult"H\n\x0cStreamResult\x12\n\n\x02id\x18\x01 \x01(\x04\x12,\n\x06result\x18\x02 \x01(\x0b\x32\x1c.krpc.schema.ProcedureResult"2\n\x08Services\x12&\n\x08services\x18\x01 \x03(\x0b\x32\x14.krpc.schema.Service"\xdb\x01\n\x07Service\x12\x0c\n\x04name\x18\x01 \x01(\t\x12*\n\nprocedures\x18\x02 \x03(\x0b\x32\x16.krpc.schema.Procedure\x12#\n\x07\x63lasses\x18\x03 \x03(\x0b\x32\x12.krpc.schema.Class\x12.\n\x0c\x65numerations\x18\x04 \x03(\x0b\x32\x18.krpc.schema.Enumeration\x12*\n\nexceptions\x18\x05 \x03(\x0b\x32\x16.krpc.schema.Exception\x12\x15\n\rdocumentation\x18\x06 \x01(\t"\xcd\x02\n\tProcedure\x12\x0c\n\x04name\x18\x01 \x01(\t\x12*\n\nparameters\x18\x02 \x03(\x0b\x32\x16.krpc.schema.Parameter\x12&\n\x0breturn_type\x18\x03 \x01(\x0b\x32\x11.krpc.schema.Type\x12\x1a\n\x12return_is_nullable\x18\x04 \x01(\x08\x12\x35\n\x0bgame_scenes\x18\x06 \x03(\x0e\x32 .krpc.schema.Procedure.GameScene\x12\x15\n\rdocumentation\x18\x05 \x01(\t"t\n\tGameScene\x12\x10\n\x0cSPACE_CENTER\x10\x00\x12\n\n\x06\x46LIGHT\x10\x01\x12\x14\n\x10TRACKING_STATION\x10\x02\x12\x0e\n\nEDITOR_VAB\x10\x03\x12\x0e\n\nEDITOR_SPH\x10\x04\x12\x13\n\x0fMISSION_BUILDER\x10\x05"Q\n\tParameter\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1f\n\x04type\x18\x02 \x01(\x0b\x32\x11.krpc.schema.Type\x12\x15\n\rdefault_value\x18\x03 \x01(\x0c",\n\x05\x43lass\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x15\n\rdocumentation\x18\x02 \x01(\t"a\n\x0b\x45numeration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12-\n\x06values\x18\x02 \x03(\x0b\x32\x1d.krpc.schema.EnumerationValue\x12\x15\n\rdocumentation\x18\x03 \x01(\t"F\n\x10\x45numerationValue\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\x12\x15\n\rdocumentation\x18\x03 \x01(\t"0\n\tException\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x15\n\rdocumentation\x18\x02 \x01(\t"\x88\x03\n\x04Type\x12(\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x1a.krpc.schema.Type.TypeCode\x12\x0f\n\x07service\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12 \n\x05types\x18\x04 \x03(\x0b\x32\x11.krpc.schema.Type"\x94\x02\n\x08TypeCode\x12\x08\n\x04NONE\x10\x00\x12\n\n\x06\x44OUBLE\x10\x01\x12\t\n\x05\x46LOAT\x10\x02\x12\n\n\x06SINT32\x10\x03\x12\n\n\x06SINT64\x10\x04\x12\n\n\x06UINT32\x10\x05\x12\n\n\x06UINT64\x10\x06\x12\x08\n\x04\x42OOL\x10\x07\x12\n\n\x06STRING\x10\x08\x12\t\n\x05\x42YTES\x10\t\x12\t\n\x05\x43LASS\x10\x64\x12\x0f\n\x0b\x45NUMERATION\x10\x65\x12\n\n\x05\x45VENT\x10\xc8\x01\x12\x13\n\x0ePROCEDURE_CALL\x10\xc9\x01\x12\x0b\n\x06STREAM\x10\xca\x01\x12\x0b\n\x06STATUS\x10\xcb\x01\x12\r\n\x08SERVICES\x10\xcc\x01\x12\n\n\x05TUPLE\x10\xac\x02\x12\t\n\x04LIST\x10\xad\x02\x12\x08\n\x03SET\x10\xae\x02\x12\x0f\n\nDICTIONARY\x10\xaf\x02"\x16\n\x05Tuple\x12\r\n\x05items\x18\x01 \x03(\x0c"\x15\n\x04List\x12\r\n\x05items\x18\x01 \x03(\x0c"\x14\n\x03Set\x12\r\n\x05items\x18\x01 \x03(\x0c";\n\nDictionary\x12-\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x1c.krpc.schema.DictionaryEntry"-\n\x0f\x44ictionaryEntry\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\r\n\x05value\x18\x02 \x01(\x0c"\x14\n\x06Stream\x12\n\n\x02id\x18\x01 \x01(\x04",\n\x05\x45vent\x12#\n\x06stream\x18\x01 \x01(\x0b\x32\x13.krpc.schema.Stream"\xf4\x03\n\x06Status\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x12\n\nbytes_read\x18\x02 \x01(\x04\x12\x15\n\rbytes_written\x18\x03 \x01(\x04\x12\x17\n\x0f\x62ytes_read_rate\x18\x04 \x01(\x02\x12\x1a\n\x12\x62ytes_written_rate\x18\x05 \x01(\x02\x12\x15\n\rrpcs_executed\x18\x06 \x01(\x04\x12\x10\n\x08rpc_rate\x18\x07 \x01(\x02\x12\x1a\n\x12one_rpc_per_update\x18\x08 \x01(\x08\x12\x1b\n\x13max_time_per_update\x18\t \x01(\r\x12\x1d\n\x15\x61\x64\x61ptive_rate_control\x18\n \x01(\x08\x12\x15\n\rblocking_recv\x18\x0b \x01(\x08\x12\x14\n\x0crecv_timeout\x18\x0c \x01(\r\x12\x1b\n\x13time_per_rpc_update\x18\r \x01(\x02\x12 \n\x18poll_time_per_rpc_update\x18\x0e \x01(\x02\x12 \n\x18\x65xec_time_per_rpc_update\x18\x0f \x01(\x02\x12\x13\n\x0bstream_rpcs\x18\x10 \x01(\r\x12\x1c\n\x14stream_rpcs_executed\x18\x11 \x01(\x04\x12\x17\n\x0fstream_rpc_rate\x18\x12 \x01(\x02\x12\x1e\n\x16time_per_stream_update\x18\x13 \x01(\x02"w\n\x12MultiplexedRequest\x12:\n\x12\x63onnection_request\x18\x01 \x01(\x0b\x32\x1e.krpc.schema.ConnectionRequest\x12%\n\x07request\x18\x02 \x01(\x0b\x32\x14.krpc.schema.Request"p\n\x13MultiplexedResponse\x12'\n\x08response\x18\x01 \x01(\x0b\x32\x15.krpc.schema.Response\x12\x30\n\rstream_update\x18\x02 \x01(\x0b\x32\x19.krpc.schema.StreamUpdateB-\n\x0bkrpc.schemaB\x04KRPC\xa2\x02\x04KRPC\xaa\x02\x10KRPC.Schema.KRPCb\x06proto3')

File "C:\ProgramData\Anaconda3\lib\site-packages\google\protobuf\descriptor.py", line 908, in init
_message.default_pool.AddSerializedFile(self.serialized_pb)

NameError: name '_message' is not defined

commented

UPDATE: updating to protobuf 3.7.0 fixed my error

commented

Closing as should be fixed by #510