web-dev-qa-db-fra.com

Erreur lors de l'importation de keras et de tensorflow

J'ai utilisé from keras.layers import dot et obtenu cette erreur en retour:

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
     17         try:
---> 18             fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
     19         except ImportError:

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\imp.py in find_module(name, path)
    295     else:
--> 296         raise ImportError(_ERR_MSG.format(name), name=name)
    297 

ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     40     sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 41   from tensorflow.python.pywrap_tensorflow_internal import *
     42   from tensorflow.python.pywrap_tensorflow_internal import __version__

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>
     27             return _mod
---> 28     _pywrap_tensorflow_internal = swig_import_helper()
     29     del swig_import_helper

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
     19         except ImportError:
---> 20             import _pywrap_tensorflow_internal
     21             return _pywrap_tensorflow_internal

ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\keras\__init__.py in <module>
      2 try:
----> 3     from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
      4 except ImportError:

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\__init__.py in <module>
     23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
     25 # pylint: enable=wildcard-import

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\__init__.py in <module>
     48 
---> 49 from tensorflow.python import pywrap_tensorflow
     50 

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     51 above this error message when asking for help.""" % traceback.format_exc()
---> 52   raise ImportError(msg)
     53 

ImportError: Traceback (most recent call last):
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\imp.py", line 296, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

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:

ImportError                               Traceback (most recent call last)
<ipython-input-14-884a93be26a0> in <module>
----> 1 from keras.layers import dot

c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\keras\__init__.py in <module>
      4 except ImportError:
      5     raise ImportError(
----> 6         'Keras requires TensorFlow 2.2 or higher. '
      7         'Install TensorFlow via `pip install tensorflow`')
      8 

ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`

J'ai amélioré Tensorflow. Réinstallez-le aussi mais n'a pas fonctionné.

2
Prashasti Nama

Hey plus que une solution pour le même problème ->

  • Solution -> 1

    1. Vérifiez que les paramètres de l'environnement de Cuda, normalement tous les paramètres de Cuda ont été ajoutés à l'environnement Windows.

    2. Copier des fichiers dans bin, lib et include de cudnn à bin, lib et include de CUDA. Normalement, le répertoire est C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA

    3. Et vous pouvez ensuite importer TENSORFLOW et exécuter votre code. Bonne chance!

  • Solution -> 2

    1. Il suffit de courir en dessous de la commande si nécessaire, puis mettez-le à la mettre à jour

    2. pip install tensorflow==1.5

0
Domadiya Bhautik