Tensorflow cannot be imported

Problem: Tensorflow cannot be imported

When I installed Tensorflow 2.3.0 (latest version at the time of writing the article) and tried to import it, I got a lot of error messages about the missing modules, so I went through each of the missing modules listed in the error message. Import with one pip, downgrade ...

However, after I finally got the following error, I couldn't proceed.

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed:The specified module cannot be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calculation1.py", line 9, in <module>
    import tensorflow as tf
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
    from tensorflow.python.eager import context
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
    from tensorflow.python import pywrap_tfe
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed:The specified module cannot be found.

It seems that there is no module called _pywrap_tensorflow_internal ... I couldn't help it, so I tried various things.

Execution environment

・ Windows 10 ・ Anaconda 3.7.6

Solution

After all, I reinstalled Anaconda and reinstalled __tensorflow == 2.0.0 __ and it worked. After that, when I upgraded to tensorflow == 2.3.0, I got the same error as above again.

pip install tensorflow==2.0.0

Recommended Posts

Tensorflow cannot be imported
Items that cannot be imported with sklearn
tar.gz cannot be expanded
Matplotlib etc. cannot be imported in VirtualEnv environment
When USB cannot be formatted
When pydub cannot be installed
Modules cannot be imported in Python on EC2 run from AWS Lambda
matplotlib image cannot be renamed and saved
Tkinter could not be imported in Python