0


I get the following error when I try to import tensorflow after installing it.
What I did:
1. pip install --upgrade tensorflow
2. Python version is 3.5.2
3. I want to install CPU-only tensorflow.
4. The OS is Windows 8.1

>>> import tensorflow
    Traceback (most recent call last):
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
        return importlib.import_module(mname)
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 986, in _gcd_import
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 577, in module_from_spec
      File "<frozen importlib._bootstrap_external>", line 906, in create_module
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
    ImportError: DLL load failed: The specified module could not be found.
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
        return importlib.import_module('_pywrap_tensorflow_internal')
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: No module named '_pywrap_tensorflow_internal'
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "C:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
        from tensorflow.python import *
      File "C:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "C:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "C:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
        raise ImportError(msg)
    ImportError: Traceback (most recent call last):
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
        return importlib.import_module(mname)
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 986, in _gcd_import
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 577, in module_from_spec
      File "<frozen importlib._bootstrap_external>", line 906, in create_module
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
    ImportError: DLL load failed: The specified module could not be found.
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\Program Files\JetBrains\PyCharm 2017.1.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
        return importlib.import_module('_pywrap_tensorflow_internal')
      File "C:\Users\Student\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ImportError: 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

2 Answers2

0

Install first anaconda Then try installing tensor flow using anaconda version from https://www.tensorflow.org/install/install_windows

Then pycharm will automatically detect tensorflow

If problem still exist then try this youtube video which will for sure help you to install in pycharm https://www.youtube.com/watch?v=83vR1Nz3dHA&t=4s

Viral
  • 47
  • 8
  • OP should not have to install Anaconda to install Tensorflow, since pip is the officially supported installation method, while Anaconda support is only community-provided and might not be reliable long term – Anthony Rossi Jul 07 '17 at 14:49
0

Just citing an answer found on another thread that is relevant to your problem :

Either error indicates that your system has not installed MSVCP140.DLL, which TensorFlow requires.

To fix this error:

  1. Determine whether MSVCP140.DLL is in your %PATH% variable.
  2. If MSVCP140.DLL is not in your %PATH%, install the Visual C++ 2015 redistributable (x64 version), which contains this DLL.

Original answer : https://stackoverflow.com/a/42011114/4895899

Anthony Rossi
  • 1,182
  • 8
  • 14