import tensorflow ModuleNotFoundError: No module named 'termcolor'

42 views Asked by At

I tried to import tensorflow, but got following error:

import tensorflow as tf
Traceback (most recent call last):

  File "/var/folders/sk/q1bd_nkn1z345sbmdty96hpn6_w5dn/T/ipykernel_5388/3793406994.py", line 1, in <module>
    import tensorflow as tf

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/__init__.py", line 38, in <module>
    from tensorflow.python.tools import module_util as _module_util

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/__init__.py", line 42, in <module>
    from tensorflow.python import data

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/data/__init__.py", line 21, in <module>
    from tensorflow.python.data import experimental

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/data/experimental/__init__.py", line 97, in <module>
    from tensorflow.python.data.experimental import service

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/data/experimental/service/__init__.py", line 419, in <module>
    from tensorflow.python.data.experimental.ops.data_service_ops import distribute

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 25, in <module>
    from tensorflow.python.data.ops import dataset_ops

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 31, in <module>
    from tensorflow.python.data.ops import iterator_ops

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 37, in <module>
    from tensorflow.python.ops import parsing_ops

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/ops/parsing_ops.py", line 24, in <module>
    from tensorflow.python.ops import parsing_config

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/ops/parsing_config.py", line 28, in <module>
    from tensorflow.python.ops.ragged import ragged_math_ops

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/ops/ragged/ragged_math_ops.py", line 29, in <module>
    from tensorflow.python.ops import map_fn

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/ops/map_fn.py", line 22, in <module>
    from tensorflow.python.autograph.impl import api as autograph

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/autograph/__init__.py", line 35, in <module>
    from tensorflow.python.autograph.core.converter import ConversionOptions

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/autograph/core/converter.py", line 68, in <module>
    from tensorflow.python.autograph.pyct import transformer

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/transformer.py", line 24, in <module>
    from tensorflow.python.autograph.pyct import pretty_printer

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/pretty_printer.py", line 18, in <module>
    import termcolor

ModuleNotFoundError: No module named 'termcolor'

I am in a conda environment py310. When I use conda list to check all packages I have, I saw the termcolor:

(py310) TUD500370:ml_lsmodel_ascat xushan$ conda list
# packages in environment at /Users/xushan/opt/anaconda3/envs/py310:
#
# Name                    Version                   Build  Channel
_anaconda_depends         2022.10                 py310_2  
...
keras                     2.13.1                   pypi_0    pypi
tensorboard               2.13.0                   pypi_0    pypi
tensorboard-data-server   0.7.1                    pypi_0    pypi
tensorflow                2.13.0                   pypi_0    pypi
tensorflow-estimator      2.13.0                   pypi_0    pypi
tensorflow-io-gcs-filesystem 0.33.0                   pypi_0    pypi
tensorflow-probability    0.14.0             pyhd3eb1b0_0  
termcolor                 2.0.1                    pypi_0    pypi
...

But when I import termcolor, I was told ModuleNotFoundError: No module named 'termcolor'...so what happened? Btw, the version of tensorflow and other dependencies are listed above.

0

There are 0 answers