onnx: binary build of onnx is failing to load libprotobuf.so.20

Hi, I installed onnx into my conda environment using:

conda install -c conda-forge onnx

This installs the following packages:

  libprotobuf        conda-forge/linux-64::libprotobuf-3.10.1-h8b12597_0
  onnx               conda-forge/linux-64::onnx-1.6.0-py36he1b5a44_0
  protobuf           conda-forge/linux-64::protobuf-3.10.1-py36he1b5a44_0

However, following the installation, when I try to import onnx I get the following error:

In [1]: import onnx
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-6f9566fa2ea7> in <module>
----> 1 import onnx

~/.conda/envs/ramitra/lib/python3.6/site-packages/onnx/__init__.py in <module>
      6 import os
      7
----> 8 from .onnx_cpp2py_export import ONNX_ML
      9 from onnx.external_data_helper import load_external_data_for_model, write_external_data_tensors
     10 from .onnx_pb import *  # noqa

ImportError: libprotobuf.so.20: cannot open shared object file: No such file or directory

I am using python 3.6.9 on my machine.

Can you please help?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 23 (3 by maintainers)

Most upvoted comments

Same issue here after installing from: conda install -c conda-forge onnx it comes with protobuf 3.10 solving by downgrading protobuf to 3.9 via: conda install -c anaconda protobuf

conda install protobuf=3.9 work for me.

Same issue here after installing from: conda install -c conda-forge onnx it comes with protobuf 3.10 solving by downgrading protobuf to 3.9 via: conda install -c anaconda protobuf

Had similar problem, except conda create -n onnx onnx -c conda-forge installs

libprotobuf        conda-forge/linux-64::libprotobuf-3.11.0-h8b12597_0
onnx               conda-forge/linux-64::onnx-1.6.0-py38he1b5a44_0
protobuf           conda-forge/linux-64::protbuf-3.11.0-py38he1b5a44_0

And import fails with following error

~$ python -c "import onnx"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/oleg/miniconda3/envs/onnx/lib/python3.8/site-packages/onnx/__init__.py", line 8, in <module>
    from .onnx_cpp2py_export import ONNX_ML
ImportError: libprotobuf.so.21: cannot open shared object file: No such file or directory

Fixed with conda install protobuf=3.10 -c conda-forge

Update: the current onnx version available on conda-forge (v1.6) only works with protobuf=3.10 (v3.10.1) right now. That is the only configuration that did not give me the mentioned error.

I don’t understand - conda install is the first installation option on the project page. Should we not use conda to install onnx? This method is currently broken, with an obscure error, and the workaround (protobuf downgrade) is only mentioned in this thread. If you don’t intend to fix it any time soon, please mention the workaround next to the conda installation command, so people don’t waste time googling this error.

Also keep in mind that conda is the default installation option for Pytorch, so quite a few Pytorch users will probably prefer conda if they want to install onnx.

Still the problem 5 months later, why is this not fixed yet?

Fixed with conda install protobuf=3.9 -c conda-forge

There might be inconsistent with conda install and pip install. When you want to uninstall some package, try both conda uninstall and pip uninstall, like conda uninstall protobuf, conda uninstall libprotobuf and pip uninstall protobuf, to make sure no PROTOBUF-LIKE package exists. Then, type conda install protobuf=3.9 and conda install -c conda-forge onnx. It works for me.