Error while import tensorflow module

13,382

Solution 1

Solution is downgrade Python to version 3.5, and install again TensorFlow. It works for me

Solution 2

The problem was the cuDNN Library for me - for whatever reason cudnn-8.0-windows10-x64-v6.0 was NOT working - I used cudnn-8.0-windows10-x64-v5.1 - ALL GOOD!

My setup working with Win10 64 and the Nvidia GTX780M:

  • Be sure you have the lib MSVCP140.DLL by checking your system/path - if not get it here
  • Run the windows installer for python 3.5.3-amd64 from here - DO NOT try newer versions as they probably won't work
  • Get the cuDNN v5.1 for CUDA 8.0 from here - put it under your users folder or in another known location (you will need this in your path)
  • Get CUDA 8.0 x86_64 from here
  • Set PATH vars as expected to point at the cuDNN libs and python (the python path should be added during the python install)

If you run Windows 32 be sure to get the 32 bit versions of the files mentioned above.

Solution 3

This is a known error. There is a file named MSVCP140.DLL, that you will need in your system to run TensorFlow. Check if this file is in your %path%. If it is not, download Visual Studio C++. It is free and you can download it here: https://www.visualstudio.com/vs/cplusplus.

Share:
13,382
Jacek
Author by

Jacek

ASP.NET programmer

Updated on June 14, 2022

Comments

  • Jacek
    Jacek almost 2 years

    I try to learn TensorFlow with Python. My problem is with import TF module. Here is my configuration: Python 3.6.1, Windows 7 (with MSVCP140.dll)

    I've installed TensorFlow by command (in power shell). It works.

    python -m pip install --upgrade tensorflow
    

    But when I run python environment and try import Tensor Flow

    import tensorflow as tf
    

    I get errors, this error raise another errors related with it, but at the beginning I want to resolve this first

    Traceback (most recent call last): File "C:\Users\Jacek\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(file)]) File "C:\Users\Jacek\AppData\Local\Programs\Python\Python36\lib\imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named '_pywrap_tensorflow'

  • Jacek
    Jacek about 7 years
    I had this file, and installed update 3 for VS C++ 2015. Do you think about specified location?
  • Markus
    Markus about 7 years
    If you had both the DLL and Visual Studio C++ installed, it is probably something failing with your python. Try downgrading python to 3.5.
  • DropHit
    DropHit about 7 years
    This is a good first step - if you still have issues see answer below - related to cuDNN version.
  • DropHit
    DropHit about 7 years
    May or may not - this is known to be caused by running the wrong version of cuDNN for CUDA when attempting to us GPU.
  • Jacek
    Jacek about 7 years
    I installed 'simple' version of TF without CUDA support
  • CodingMatters
    CodingMatters over 4 years
    anyone know if these instructions need to be updated in 2019? about to tackle this. I have installed anaconda in ubuntu 18.40 on windows 10 current version. and followed the instructions on tensorflow.org to install tensorflow (CPU) version. this resulted in python3.7 in addition to th default python 2.7 included in ubuntu. trying to get jupyter notebook version running, sudo apt install jupyter-core python3-notebook jupyter python-ipykernel this installed another version of python (3.6)
  • Heisenberg
    Heisenberg about 4 years
    This is not a solution.