I'm trying to get tensorflow to work on my Windows 10 machine.
I have Cude 8 and CuDNN 5.1 installed and added to the %path%.
Installed Python 3.5.4 then proceeded to install TensorFlow by executing
pip3 install --upgrade tensorflow-GPU. The computer is running a GeForce 1060.
Here is what I get when I try to import TensorFlow:
import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\morit\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\morit\AppData\Local\Programs\Python\Python35\lib\importlib__init__.p>y", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 985, in _gcd_import
File "", line 968, in _find_and_load
File "", line 957, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 938, in create_module
File "", 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 below:
Traceback (most recent call last):
File "C:\Users\morit\AppData\Local\Programs\Python\Python35\lib\site->packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\morit\AppData\Local\Programs\Python\Python35\lib\site->packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\morit\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\morit\AppData\Local\Programs\Python\Python35\lib\importlib__init__.p>y", 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 "", line 1, in
File "C:\Users\morit\AppData\Local\Programs\Python\Python35\lib\site->packages\tensorflow__init__.py", line 24, in
from tensorflow.python import *
File "C:\Users\morit\AppData\Local\Programs\Python\Python35\lib\site->packages\tensorflow\python__init__.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\morit\AppData\Local\Programs\Python\Python35\lib\site->packages\tensorflow\python\pywrap_tensorflow.py", line 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\morit\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\morit\AppData\Local\Programs\Python\Python35\lib\importlib__init__.p>y", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 985, in _gcd_import
File "", line 968, in _find_and_load
File "", line 957, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 938, in create_module
File "", 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\morit\AppData\Local\Programs\Python\Python35\lib\site->packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\morit\AppData\Local\Programs\Python\Python35\lib\site->packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\morit\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\morit\AppData\Local\Programs\Python\Python35\lib\importlib__init__.p>y", 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
above this error message when asking for help.
I've faced this error during my setup. But my environment is Windows 7.
Uninstalled the Python and reinstalled python 3.5 and continued the setup.
Next followed this link to resolve the DLL load failed error:
https://www.tensorflow.org/versions/r0.12/get_started/os_setup#pip_installation_on_windows
Related
I am trying to create an executable with pyinstaller from a python project. The project uses osgeo modules gdal and osr:
from osgeo import gdal
from osgeo import osr
pyinstaller runs successfully, but when I try to execute the file I encounter the following errors:
Traceback (most recent call last): File "osgeo_init_.py", line
29, in swig_import_helper File "importlib_init_.py", line 127, in
import_module File "", line 1030, in
_gcd_import File "", line 1007, in _find_and_load File "", line 984, in _find_and_load_unlocked ModuleNotFoundError: No module named 'osgeo._gdal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "[...].py", line 1, in
File "PyInstaller\loader\pyimod03_importers.py", line 495,
in exec_module File "[...]_init_.py", line 1, in File
"PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "[...]\GeoMap.py", line 1, in File
"PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "osgeo_init_.py", line 45, in File
"osgeo_init_.py", line 41, in swig_import_helper ImportError:
Traceback (most recent call last): File "osgeo_init_.py", line
29, in swig_import_helper File "importlib_init_.py", line 127, in
import_module File "", line 1030, in
_gcd_import File "", line 1007, in _find_and_load File "", line 984, in _find_and_load_unlocked ModuleNotFoundError: No module named 'osgeo._gdal'
On Windows, with Python >= 3.8, DLLs are no longer imported from the
PATH. If gdalXXX.dll is in the PATH, then set the
USE_PATH_FOR_GDAL_PYTHON=YES environment variable to feed the PATH
into os.add_dll_directory(). [3268] Failed to execute script '[removed
name]' due to unhandled exception!
I am using Python 3.9 and pyinsatller 5.0.1, gdal 3.4.2.
Has anyone encountered a similar problem and found a solution?
I am trying to execute the command
python -c "from keras import backend".
But while executing it I am getting the following error.
(aind-cv) C:\Users\Harikesh>python -c "from keras import backend"
Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 985, in _gcd_import
File "", line 968, in _find_and_load
File "", line 957, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 938, in create_module
File "", 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\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\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\Harikesh\Anaconda3\envs\aind-cv\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 "", line 1, in
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\__init__.py", line 3, in
from . import utils
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\utils\__init__.py", line 6, in
from . import conv_utils
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\utils\conv_utils.py", line 9, in
from .. import backend as K
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\backend\__init__.py", line 84, in
from .tensorflow_backend import *
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in
import tensorflow as tf
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\__init__.py", line 24, in
from tensorflow.python import *
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\__init__.py", line 51, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 985, in _gcd_import
File "", line 968, in _find_and_load
File "", line 957, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 938, in create_module
File "", 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\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Harikesh\Anaconda3\envs\aind-cv\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\Harikesh\Anaconda3\envs\aind-cv\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
above this error message when asking for help.
I am using Anaconda and referred that website to solve the problem but it is not solved. I am trying to do the tasks provided in this. My tensorflow codes are working fine but I am unable to use keras only.
As I cannot comment I am writing this as an answer.
Make sure you have the lib MSVCP140.DLL. You can check in system->path variable. If not you can download it from here link. Also make sure you download the correct 32/64 bit for your system.
Also possible duplicate of this
I am working on Python and wanted to install Tensorflow to play with some machine learning stuff. I followed the steps in this link https://www.tensorflow.org/install/install_windows. However I got the error during import when I run the validate program.
I am not sure what happened, thank you for your help.
ErrorDuringImport: problem in tensorflow - ImportError: Traceback (most recent call last): File "D:\Work\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper return importlib.import_module(mname) File "D:\Work\Python36\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 658, in _load_unlocked File "", line 571, in module_from_spec File "", line 922, in create_module File "", line 219, 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 "D:\Work\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in from tensorflow.python.pywrap_tensorflow_internal import * File "D:\Work\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in _pywrap_tensorflow_internal = swig_import_helper() File "D:\Work\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper return importlib.import_module('_pywrap_tensorflow_internal') File "D:\Work\Python36\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) 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.
pip list
I get the following error while attempting to import TensorFlow. I tried rolling back to C++ Redist. 2015 (from 2017) and still not working. Win10, Python 3.5(64)
Traceback (most recent call last): File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 18, in swig_import_helper return importlib.import_module(mname)
File "C:\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level) File "",
line 986, in _gcd_import File "", line 969, in _find_and_load File "",
line 958, in _find_and_load_unlocked File "", line 666, in
_load_unlocked File "", line 577, in module_from_spec File "", line 914, in create_module File "", 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:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 41, in from tensorflow.python.pywrap_tensorflow_internal import *
File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 21, in
_pywrap_tensorflow_internal = swig_import_helper() File "C:\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:\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 "", line 1, in File
"C:\Python35\lib\site-packages\tensorflow_init_.py", line 24, in from
tensorflow.python import * File
"C:\Python35\lib\site-packages\tensorflow\python_init_.py", line 51,
in from tensorflow.python import pywrap_tensorflow File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 52, in raise ImportError(msg) ImportError: Traceback (most recent
call last): File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 18, in swig_import_helper return importlib.import_module(mname)
File "C:\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level) File "",
line 986, in _gcd_import File "", line 969, in _find_and_load File "",
line 958, in _find_and_load_unlocked File "", line 666, in
_load_unlocked File "", line 577, in module_from_spec File "", line 914, in create_module File "", 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:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 41, in from tensorflow.python.pywrap_tensorflow_internal import *
File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 21, in
_pywrap_tensorflow_internal = swig_import_helper() File "C:\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:\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
above this error message when asking for help.
My Working setup in Windows 10 and GTX960M:
Install python 3.5.x
Microsoft visual studio 2015 community edition.
Download and install CUDA toolkit 8.0
Download CuDNN v5.1.
Set CUDA_HOME (\CUDA) and %CUDA_HOME%\bin in PATH.
Extract the cuDNN files to a folder and add that location(the folder where bin,lib, include folders are) also to PATH make sure that cuDNN DLLs are properly set in %PATH%.
Copy the respective files from cuDNN to folders in cuda installation directory(This solved my issues):
copy cudnn64_5.dll to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin.
copy cudnn.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include.
copy cudnn.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64.
Make sure that I have MSVCP140.dll in C:\Windows\System32 and C:\Windows\SysWOW64. If not download it from here: https://www.microsoft.com/en-us/download/details.aspx?id=53587 and install it.
I strongly think these versioning is a bit important in this case.
I tried using cuDNN 6.0 which failed. but 5.1 worked.
I thought I had installed tensorflow correctly. I am using python 3.5.2 so it should work. I followed the instructions on the website and installed the CPU only version of tensorflow using pip which seemed to work. However, when, in python, I try to:
import tensorflow as tf
I get the error:
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\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 956, in _find_and_load_unlocked
ImportError: No module named 'tensorflow.python._pywrap_tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow')
File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
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\------\Documents\-----\Computing\Python\Neural Networks\test.py", line 1, in <module>
import tensorflow as tf
File "C:\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Python35\lib\site-packages\tensorflow\python\__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\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 956, in _find_and_load_unlocked
ImportError: No module named 'tensorflow.python._pywrap_tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow')
File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Does anyone know why this error is occurring and how I might be able to fix it?