Home > Back-end >  "import tensorflow" results in error: No module named 'tensorflow.python.eager.polymo
"import tensorflow" results in error: No module named 'tensorflow.python.eager.polymo

Time:12-03

Python 3.9.12.
Windows 10.
jupyterlab 3.3.2.

Import tensorflow

When I try to import Tensorflow, I get the following 'tensorflow.python.eager.polymorphic_function' error.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In [44], line 1
----> 1 import tensorflow

File ~\OD13\TFODCourse\tfod13\lib\site-packages\tensorflow\__init__.py:45
     42 from tensorflow.python import tf2 as _tf2
     43 _tf2.enable()
---> 45 from ._api.v2 import __internal__
     46 from ._api.v2 import __operators__
     47 from ._api.v2 import audio

File ~\OD13\TFODCourse\tfod13\lib\site-packages\tensorflow\_api\v2\__internal__\__init__.py:14
     12 from . import eager_context
     13 from . import feature_column
---> 14 from . import function
     15 from . import graph_util
     16 from . import mixed_precision

File ~\OD13\TFODCourse\tfod13\lib\site-packages\tensorflow\_api\v2\__internal__\function\__init__.py:8
      3 """Public API for tf.__internal__.function namespace.
      4 """
      6 import sys as _sys
----> 8 from tensorflow.python.eager.polymorphic_function.polymorphic_function import Function
      9 from tensorflow.python.eager.polymorphic_function.quarantine import defun_with_attributes

ModuleNotFoundError: No module named 'tensorflow.python.eager.polymorphic_function'

My workflow is based on this tutorial: https://www.youtube.com/watch?v=yqkISICHH-U

I found the following answer, but I'm not understanding how to implement the TFLite Authoring Tool to solve this problem: https://stackoverflow.com/questions/74177865/tensorflow-python-eager-polymorphic-function-no-module-error-on-imports

CodePudding user response:

To answer my own question: I created a conda environment and installed an older version of Python (3.7) in it and that seems to have fixed the problem.

I found these links to be helpful:
How to downgrade the Python Version from 3.8 to 3.7 on windows?
conda install downgrade python version
Jupyter Notebook - Cannot Connect to Kernel
How to find the version of jupyter notebook from within the notebook
pip command to downgrade jupyter notebook
How to check python anaconda version installed on Windows 10 PC?
https://towardsdatascience.com/get-your-conda-environment-to-show-in-jupyter-notebooks-the-easy-way-17010b76e874

  • Related