programmer pro
programmer pro

Reputation: 179

Import TensorFlow not working 'could not find dll '

When I installed TensorFlow using pip. It worked but when I run the code:

import tensorflow as tf

It showed me the error

Traceback (most recent call last):
  File "c:\Users\User\Desktop\sanu\A programming\python\Python Progams\comparing\balance.py", line 9, in <module>
    import tensorflow as tf
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 30, in <module>
    self_check.preload_check()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\platform\self_check.py", line 60, in preload_check
    % " or ".join(missing))
ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads

I went to the manual page tensorflow.org/install/pip but I could not understand how to install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019. How can I solve this problem?

Upvotes: 0

Views: 1427

Answers (1)

user13053610
user13053610

Reputation:

If you are using tensorflow-GPU then you must install Nvidia Cuda for this purpose.

The proper version of Cuda must be installed check the TensorFlow website for the Cuda versions corresponding to different TensorFlow versions.

After proper installation, it should work.

If you are not having GPU in your PC.

Use normal TensorFlow

My suggestion is if you are a beginner try google colab.

https://colab.research.google.com/

Upvotes: 1

Related Questions