-2

I am trying to import TensorFlow using my Conda environment. I received the ImportError message below. I tried to solve it by creating a new environment, installing TensorFlow 2, and trying with this new environment, but the error still appeared.

It was work yesterday, and I don't know what is happen today.

**>>> import tensorflow**
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Saja\AppData\Roaming\Python\Python38\site-packages\tensorflow\__init__.py", line 51, in <module>
    from ._api.v2 import compat
  File "C:\Users\Saja\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\__init__.py", line 37, in <module>
    from . import v1
  File "C:\Users\Saja\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\__init__.py", line 30, in <module>
    from . import compat
  File "C:\Users\Saja\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\compat\__init__.py", line 37, in <module>
    from . import v1
  File "C:\Users\Saja\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\compat\v1\__init__.py", line 52, in <module>
    from tensorflow._api.v2.compat.v1 import math
  File "C:\Users\Saja\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\math\__init__.py", line 109, in <module>
    from tensorflow.python.ops.gen_math_ops import segment_sum_v2
**ImportError:** cannot import name 'segment_sum_v2' from 'tensorflow.python.ops.gen_math_ops' (C:\Users\Saja\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gen_math_ops.py)
AcK
  • 2,063
  • 2
  • 20
  • 27
Saja
  • 1
  • 1
  • Welcome to Stack Overflow! [Under what circumstances may I add "urgent" or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) – Adriaan Nov 29 '22 at 14:26
  • @ack Adding the [tag:python] tag is useful, but removing the [tag:python-3.x] tag is not. I have generally voted to reject your recent edits because of this. Please don't be discouraged from adding the [tag:python] tag where it's missing, but keep the version tag, too (and probably try to improve the posts if you are proposing an edit anyway). – tripleee Dec 03 '22 at 13:56

1 Answers1

0

I faced the same issue a couple of days back. I would suggest you to download Anaconda 2020.02 for a seamlessly smooth experience with TensorFlow 2.

After installation;

You can execute the following instructions and command to solve the issue: (do not include inverted commas)

Open Anaconda Prompt

type: create --name py3-TF2.0 python = 3

press y to continue After successful completion:

type conda activate py3-TF2.0

type pip install matplotlib

type pip install tensorflow==2.3.0

type conda deactivate

type pip install ipykernel

type conda install nb_conda_kernels

Now exit the Anaconda prompt and open the Anaconda Navigator application. Switch to py3-TF2.0 from the base environment using the Environment tab. Install Jupyter in the specified environment. After successful installation, open Jupyter notebook and switch to py3-TF2.0 kernel using Kernel Tab. You're good to go for using TensorFlow 2.

LSeu
  • 630
  • 7
  • 17
  • Thanx for your answer, but I already have Conda version 22.9.0 – Saja Nov 29 '22 at 14:33
  • I got this error when Install matplotlib ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. tensorflow-intel 2.11.0 requires flatbuffers>=2.0, which is not installed. tensorflow-intel 2.11.0 requires grpcio<2.0,>=1.24.3, which is not installed. tensorflow-intel 2.11.0 requires libclang>=13.0.0, which is not installed. tensorflow-intel 2.11.0 requires tensorflow-estimator<2.12,>=2.11.0, which is not installed. .................>* – Saja Nov 29 '22 at 14:36
  • Please, I do what you said. I faced another error which is: RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd ImportError: numpy.core.multiarray failed to import – Saja Nov 29 '22 at 16:07