I'm trying to get a simple Python script up to convert protobuf files into json files (required format for what I'm doing at work).
I've seen some recommendations to upgrade to Python 3.6.1 (I'm at 3.6.0), up/downgrade google.protobuf. Neither solution helped.
def convert_to_json(directory: str):
os.chdir(jsonPath)
for (root, dirs, files) in os.walk(os.getcwd()):
for file_ in files:
if os.path.dirname(file_) != root and file_.endswith(".pb"):
json_file: str = MessageToJson(file_)
file_name = (os.path.dirname(file_).split('\\')[-1]) + ".json"
file_path = os.join(jsonPath, file_name)
with open(file_path, "w") as new_file:
new_file.write(json_file)
I expected to have this simply run and convert the slew of .pb files (Google Fonts) to .json files to be able to categorize the fonts within my program.
What happened was that I got the following error:
Traceback (most recent call last):
File "[path to pythonfile].py", line 5, in <module>
from protobuf.json_format import MessageToJson
File "C:\Python\Lib\site-packages\google\protobuf\json_format.py", line 63, in <module>
from google.protobuf import descriptor
File "[pathToVenv]\venv\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
At first glance - duh, I don't have "_message" in my google.protobuf.pyext package, but I've tried various version of google.protobuf all acquired from pip. Pip did just fine installing every other package I have, so it's not likely an issue with pip. There is however a file called, "cpp_message.py" in that same package, so I'm not sure where to go from here.