0
votes

i have installed "Anaconda3-2020.07-Windows-x86_64" and python "python-3.8.0". after that, i have installed keras and then tensorflow. but each time i am running the code "import keras" in spyder, the problem is showing that:

***Traceback (most recent call last):

File "C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in

from tensorflow.python._pywrap_tensorflow_internal import *

ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.

During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\Asus\anaconda3\lib\site-packages\keras_init_.py", line 3, in from tensorflow.keras.layers.experimental.preprocessing import RandomRotation File "C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\tensorflow_init_.py", line 41, in

from tensorflow.python.tools import module_util as _module_util

File "C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\tensorflow\python_init_.py", line 40, in

from tensorflow.python.eager import context

File "C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\context.py", line 35, in

from tensorflow.python import pywrap_tfe

File "C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in

from tensorflow.python import pywrap_tensorflow

File "C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in raise ImportError(msg)

ImportError: Traceback (most recent call last): File "C:\Users\Asus\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in

from tensorflow.python._pywrap_tensorflow_internal import *

ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.

Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/errors for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.

During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in

import keras

File "C:\Users\Asus\anaconda3\lib\site-packages\keras_init_.py", line 5, in raise ImportError( ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow ----------------------------------------------***

now, i dont know what is the problem mainly. because my tensorflow version shows that its 2.3.0.. i dont know what iis the problem. please, any one help.

1
I would say your first problem is that you're on Windows. Of the three main OS'es: Windows, Mac, and Linux, Windows is easily the worst for trying to install these Python libraries. You should be able to do it fairly well on a Mac, and even better on Linux. The very best would be (x)ubuntu 16.04, 18.04, or 20.04, because then you could use the Lambda Labs stack. If you installed Anaconda, why did you also install Python? Anaconda installs Python. How did you install keras and tensorflow?Adrian Keister
from tensorflow import kerasNicolas Gervais
@NicolasGervais If there is a problem importing TensorFlow, it does not matter if you import tf.keras or keras, you will get the same error anyway. Generic comments like that do not really help.Dr. Snoopy
Can you follow the steps mentioned in this ans and see if the issue still persists.Aniket Bote
I had similar problems. They went away when I down graded to python 3.7. Also I found the best way to install tensorflow is using conda not pip. Conda will install the Cuda Toolkit and the proper version of cuDNN. Pip does not install theseGerry P

1 Answers

0
votes

From comments

I had to create a environment in anaconda, named the environment as tensorflow, and created the environment based on python 3.6. In that environment, i imported tensorflow, keras separately and installed the spyder, jupyter notebook . after all these steps, it worked (paraphrased from kazi fahim lateef)

Steps to create virtual environment in anaconda

# Create environment
conda create --name TF

# When conda asks you to proceed, type y:
proceed ([y]/n)?

# Activate virtual environment
conda activate TF

# Install the TF Version 
conda install tensorflow

# Install the Keras Version 
conda install Keras

Note: From TF 2.0, onwards keras are integrated with TF. You can refer tf.keras module for more details.