Search code examples
pythonpython-3.xcaffe2

python (onnx) cannot import name X


System info: Ubuntu 16.04

Python 3.6.5 in anaconda3/envs/testcaffe/bin/python3

Anaconda3 4.5.2

CPU only

I installed Caffe2 by conda install -c caffe2 caffe2 for python to find onnx i set the PYTHONPATH to /home/username/WorkStuff/anaconda3/envs/testcaffe/lib/python3.6/site-packages/caffe2/python

importing onnx import onnx in python works fine, but when i tried to run converter script provided in tutorial i get this:

File "converter.py", line 2, in <module>
import caffe2.python.onnx.frontend
File "/home/username/WorkStuff/anaconda3/envs/testcaffe/lib/python3.6/site- 
packages/caffe2/python/onnx/frontend.py", line 22, in <module>
from onnx import (defs, checker, helper, numpy_helper, mapping,
File "/home/username/WorkStuff/anaconda3/envs/testcaffe/lib/python3.6/site- 
packages/caffe2/python/onnx/helper.py", line 9, in <module>
from onnx.backend.base import namedtupledict
File "/home/username/WorkStuff/anaconda3/envs/testcaffe/lib/python3.6/site- 
packages/caffe2/python/onnx/backend.py", line 33, in <module>
from onnx import checker, GraphProto, TensorProto, AttributeProto, 
ModelProto
ImportError: cannot import name 'checker'

checker.h is located in /home/username/WorkStuff/anaconda3/envs/testcaffe/include/onnx although there are no ...Proto files in my testcaffe directory

if i just run Python and write import onnx.checker it returns ModuleNotFoundError: No module named 'onnx.checker'

seems like onnx cant import any of its modules

Is there anything i simply miss or don't understand? Thank you for your help


Solution

  • Apparently the newer version of ONNX does not have these files.

    I tested ONNX v1.0.0 and everything is there. Please install it by using: conda install -c willyd onnx

    This works on linux x64, but I'm not sure how to fix on other systems.