I am getting this error while trying to generate protobuf classes in python from .proto file. i installed protobuf successfully and added it to my system PATH.
ERROR-
C:\protoc-29.3-win64\include\google\protobuf>protoc --python_out=. *.proto
google/protobuf/any.proto:158:10: “google.protobuf.Any.type_url” is already defined in file “any.proto”.
google/protobuf/any.proto:161:9: “google.protobuf.Any.value” is already defined in file “any.proto”.
google/protobuf/any.proto:128:9: “google.protobuf.Any” is already defined in file “any.proto”.
google/protobuf/type.proto:35:1: Import “google/protobuf/any.proto” was not found or had errors.
google/protobuf/type.proto:182:3: “google.protobuf.Any” seems to be defined in “any.proto”, which is not imported by “google/protobuf/type.proto”. To use it here, please add the necessary import.
api.proto:36:1: Import “google/protobuf/type.proto” was not found or had errors.
api.proto:63:12: “Option” is not defined.
api.proto:95:3: “Syntax” is not defined.
api.proto:116:12: “Option” is not defined.
api.proto:119:3: “Syntax” is not defined.
Hello @Daljit_singh,
Welcome to the Upstox Community!
We are checking this and will get back to you soon with an update. Thanks.
Hi @Daljit_singh
This appears to be a local setup issue. You might find this Stack Overflow post helpful.
To simplify user experience, we have implemented feeder functions for websockets that handle binary data decoding and offer user-friendly functionality.
Please refer to our Python SDK documentation on Streamer Functions for more information.
Thank you.
Solved !!! If anyone is facing same issue, then just generate protobuf classes individually. Use this command in CMD >>> protoc --proto_path=. --python_out=. myfile.proto.
Just go to your .proto file directory for, e.g- (C:\protoc-29.3-win64\include\google\protobuf) copy the name of each proto file and put that file name in place of (myfile.proto) in the above command line.
please ensure that you are in correct directory.
If face similar problem just replay on this topic
Thanks @Daljit_singh for posting your solution.
@Daljit_singh, upstox_python_sdk version please?
@ayappan_chellappan I am using Upstox python sdk version 3 Or V3
@Daljit_singh , In V3 I faced below error on integrating protobuf, but it was working fine with V2. So I moved to upstox_client.MarketDataStreamerV3().
Did you face this error?
import MarketDataFeed_pb2 as pb
File “/MarketDataFeed_pb2.py”, line 34, in
_globals[‘_MARKETINFO_SEGMENTSTATUSENTRY’]._loaded_options = None
No, i didn’t face this issue. I can suggest you to remove old files of protobuf and old files for v2 and make a fresh of latest protobuf and V3 files. Secondly download new files from upstox v3 github page. There is folders for market data feed in which you will get v3 compatible python files. I highly encourage you to read their detailed documentation. upstox-python/examples/websocket/market_data/v3 at master · upstox/upstox-python · GitHub