Python protobuf "from google.protobuf.pyext import _message" - "ImportError: DLL load failed: The specified procedure could not be found"

10,520

Solution 1

the solution is to downgrade your protobuf to 3.6.0 instead of 3.6.1

Solution 2

I struggled with this error when I started to play with TensorFlow 2 and Keras. After almost two hours trying to solve the error, this combination worked: - python 3.6.8 (3.6.0 didn't work) - pip 20.0.2 - protobuf 3.8.0 (3.6 didn't worked for me, maybe because TensorFlow 2)

bw, -Sami-

Share:
10,520
GrowingCode247
Author by

GrowingCode247

I absolutely love to do anything that involves creating new objects in the world, which is why I am a Computer Science Major that is quite obsessed with coding! :D I feel as though, for a Computer Science Major, however, I don't know quite enough about Computer Hardware/ the inner-workings of Software and how to debug it enough to be proud of the title! Learning is something I take seriously and I would be incredibly thrilled if I would be able to gain knowledge of the aforementioned topics to become more comfortable with both my experiences with the beautiful machine I code (and of course play videogames) on and being able to help others at the same time! Help me become a SUPER SuperUser, guys! :)

Updated on June 21, 2022

Comments

  • GrowingCode247
    GrowingCode247 almost 2 years

    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.

  • Laura Baker
    Laura Baker about 4 years
    after a long time trying different peoples solutions, this one worked for me. Thanks
  • RonVibbentrop
    RonVibbentrop about 4 years
    I'm glad that I was able to help you. :)
  • Daniel
    Daniel almost 4 years
    This is the only answer that helped me
  • Simas Joneliunas
    Simas Joneliunas over 2 years
    This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review