0

I have a new env in conda and if I run the following command after activating the env, it will be successful:

python -c "import tf2onnx"

But, if I run the same command (after activating the env) with Jupyter notebook, I got the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-9d842ab860c9> in <module>
----> 1 import tf2onnx

C:\Miniconda3\envs\tf\lib\site-packages\keras2onnx\ktf2onnx\tf2onnx\__init__.py in <module>
     11 from .version import version as __version__
     12 from . import logging
---> 13 from tf2onnx import tfonnx, utils, graph, graph_matcher, shape_inference, schemas  # pylint: disable=wrong-import-order

C:\Miniconda3\envs\tf\lib\site-packages\keras2onnx\ktf2onnx\tf2onnx\tfonnx.py in <module>
     23 import tf2onnx.onnx_opset  # pylint: disable=unused-import
     24 import tf2onnx.custom_opsets  # pylint: disable=unused-import
---> 25 from tf2onnx.graph import Graph
     26 from tf2onnx.graph_matcher import OpTypePattern, GraphMatcher
     27 from tf2onnx.rewriter import *  # pylint: disable=wildcard-import

C:\Miniconda3\envs\tf\lib\site-packages\keras2onnx\ktf2onnx\tf2onnx\graph.py in <module>
     19 
     20 from distutils.version import StrictVersion
---> 21 from onnx import helper, numpy_helper, shape_inference, OperatorSetIdProto, AttributeProto, version
     22 from tf2onnx import utils, __version__
     23 from tf2onnx.utils import port_name, find_opset

ImportError: cannot import name 'shape_inference'

What is the difference between running this command with or without jupyter that causes this error?

Thanks in advance

Mohammad
  • 1,006
  • 2
  • 15
  • 29
  • If you have multiple conda environments, this can usually lead to having multiple kernels within Jupyter. Can you double check to make sure you're using the same environment in both places? – cwalvoort May 27 '19 at 14:19
  • I checked and I only have one conda env. – Mohammad May 28 '19 at 11:23
  • Try updating to the latest versions of everything if you're not there already. It is working fine for me with tf2onnx 1.5.1, tensorflow 1.13.1, and python 3.7.3. – cwalvoort May 28 '19 at 12:16
  • I tried several scenarios, one includes 'conda clean -all' and then delete all envs and create a new one with everything fresh and updated. But still getting the same error! – Mohammad May 30 '19 at 08:37
  • Can you tell me what version of `onnx` you have by running `pip show onnx` within the environment?I have the latest version which is 1.5.0. – cwalvoort May 30 '19 at 12:33
  • I also have the latest version: 1.5.0 – Mohammad May 31 '19 at 10:24
  • I apologize, but I cannot recreate your issue. Unfortunately, it looks like a common solution to uninstall/reinstall anaconda to fix issues. Maybe give that a go? – cwalvoort May 31 '19 at 19:59

0 Answers0