Error installing TensorFlow on Windows 10 (Python 3.8.3) - python

On Windows 10 with Python 3.8.3. I installed TensorFlow using
pip install tensorflow==2.0.0
but get the following error. Any recommendations on how I can fix this?
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-17-07ec96d933aa> in <module>
3 import matplotlib as mpl
4 import sklearn
----> 5 import tensorflow as tf
6 from tensorflow import keras
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\__init__.py in <module>
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
39
---> 40 from tensorflow.python.eager import context
41
42 # pylint: enable=wildcard-import
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\context.py in <module>
33 from tensorflow.core.protobuf import config_pb2
34 from tensorflow.core.protobuf import rewriter_config_pb2
---> 35 from tensorflow.python import pywrap_tfe
36 from tensorflow.python import tf2
37 from tensorflow.python.client import pywrap_tf_session
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tfe.py in <module>
26
27 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import
---> 28 from tensorflow.python import pywrap_tensorflow
29 from tensorflow.python._pywrap_tfe import *
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\sunel\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
Failed to load the native TensorFlow runtime.

Python 3.8 support starts TensorFlow 2.2 or later. Hence you are facing above issue.
You can install latest version of Tensorflow using pip install tensorflow. TensorFlow 2 packages require a pip version > 19.0.
You need to download and install/update the Microsoft Visual C++ 2015-2019 Redistributable (x64) from here.
If you are still facing DLL load failed errors, possible reasons are
Your CPU/Python is on 32 bits (It should be 64 bit)
There is a library that is in a different location/not installed on your system that cannot be loaded.
For more details please refer here.

Related

Import error for tensorflow, why is this happening?

enter image description hereImportError Traceback (most recent call last)
~\AppData\Local\Programs\Python\Python310\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in
61 try:
---> 62 from tensorflow.python._pywrap_tensorflow_internal import *
63 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: Module use of python310.dll conflicts with this version of Python.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
in
----> 1 import tensorflow
~\AppData\Local\Programs\Python\Python310\lib\site-packages\tensorflow_init_.py in
35 import typing as _typing
36
---> 37 from tensorflow.python.tools import module_util as _module_util
38 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
39
~\AppData\Local\Programs\Python\Python310\lib\site-packages\tensorflow\python_init_.py in
34 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
35
---> 36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
37 from tensorflow.python.eager import context
38
~\AppData\Local\Programs\Python\Python310\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in
76 except ImportError:
77 raise ImportError(
---> 78 f'{traceback.format_exc()}'
79 f'\n\nFailed to load the native TensorFlow runtime.\n'
80 f'See https://www.tensorflow.org/install/errors '
ImportError: Traceback (most recent call last):
File "C:\Users\Imran\AppData\Local\Programs\Python\Python310\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 62, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: Module use of python310.dll conflicts with this version of Python.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors for some common causes and solutions.
If you need help, create an issue at https://github.com/tensorflow/tensorflow/issues and include the entire stack trace above this error message.

Tensorflow 2.4 - DLL load failed while importing _pywrap_tensorflow_internal

I use TensorFlow 2.4 on Windows 10 with Python 3.8 (I have Python 3.9 and 3.6 installed too) within a virtual environment ml2u where only TensorFlow 2.4 is installed so far by pip install tensorflow. I get the error messages below by trying to import TensorFlow in a notebook. As recommended in other posts I have installed Microsoft visual C++ redistributable which led to the installation of MS Visual and VC_redist.x64.exe.
import tensorflow as tf
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-64156d691fe5> in <module>
----> 1 import tensorflow as tf
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\__init__.py in <module>
37 # go/tf-wildcard-import
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
---> 39 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
40
41 from tensorflow.python.eager import context
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
----
The shell produced followint output while running jupyter:
[W 20:51:12.010 NotebookApp] Notebook Untitled.ipynb is not trusted
[I 20:51:14.060 NotebookApp] Kernel started: 0d0455bd-ade8-4128-b273-0b24e8d9228f, name: ml2u
You might be facing this issue because you are running 32-bit python or 32-bit OS. And also check does your CPU supports AVX instructions.
Please take a look at system requirements and check if you have correct dependencies installed.

can't import tensorflow in jupyter notebook

whenever trying to import deep learning library like tensorflow, keras show error
import tensorflow
ImportError Traceback (most recent call last)
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-3-370f0fe8bb94> in <module>
----> 1 import tensorflow
~\anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
~\anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
37 # go/tf-wildcard-import
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
---> 39 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
40
41 from tensorflow.python.eager import context
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\Gokul\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
While searching for your issue, I found the following:
https://github.com/tensorflow/tensorflow/issues/23683
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed
In my opinion, uninstall tensorflow, if you have installed it using pip and reinstall using conda.
conda install -c anaconda tensorflow
Modify to tensorflow-gpu in case you need that, and before executing above command, make sure you have created a fresh environment in conda. Do not install in base!

Unable to Find Tensorflow Module in Jupyter Notebooks Despite Being Installed

Been running in circles for a couple hours here. Using Python 3 in Jupyter notebooks, tensorflow 2.3.1 is installed (confirmed by running pip freeze).
When I attempt to import tensorflow though:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-16-d6579f534729> in <module>
----> 1 import tensorflow
~\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
~\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
39
---> 40 from tensorflow.python.eager import context
41
42 # pylint: enable=wildcard-import
~\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py in <module>
33 from tensorflow.core.protobuf import config_pb2
34 from tensorflow.core.protobuf import rewriter_config_pb2
---> 35 from tensorflow.python import pywrap_tfe
36 from tensorflow.python import tf2
37 from tensorflow.python.client import pywrap_tf_session
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py in <module>
26
27 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import
---> 28 from tensorflow.python import pywrap_tensorflow
29 from tensorflow.python._pywrap_tfe import *
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\REDACTED\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I have deleted and reinstalled the tensorflow module as well.
Any help would be very much appreciated!
The error is because Tensorflow requires Microsoft Visual C++ Redistributable for Visual Studio 2015,2017,2019 as shown in the installation step on the Tensorflow.org

Error-Rock paper scissors game using tensorflow,(Import Error and DLL load error)

This is the error message received
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-2-efc5d8c872c0> in <module>
1 import cv2
2 import numpy as np
----> 3 import tensorflow as tf
4 from keras_squeezenet import SqueezeNet
5 from keras.optimizers import Adam
~\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
~\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
39
---> 40 from tensorflow.python.eager import context
41
42 # pylint: enable=wildcard-import
~\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py in <module>
33 from tensorflow.core.protobuf import config_pb2
34 from tensorflow.core.protobuf import rewriter_config_pb2
---> 35 from tensorflow.python import pywrap_tfe
36 from tensorflow.python import tf2
37 from tensorflow.python.client import pywrap_tf_session
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py in <module>
26
27 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import
---> 28 from tensorflow.python import pywrap_tensorflow
29 from tensorflow.python._pywrap_tfe import *
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\Kishore\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
This is regarding the rock paper scissors game using tensorflow. This error occured when I tried to train my model. As far as I know I have installed all the required modules and packages but still this error pops up.
1.Check whether cpu support AVX instructions sets.See hardware requirements
2.Check whether you are installing 64 bit version https://www.tensorflow.org/install/source_windows
3.Check whether installed latest version of Microsoft Visual C++ or not
https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0
4.Make sure you have updated environment path for cuda.
5.Check if there is a library that is in a different location/not installed on your system that cannot be loaded
Ref-
https://github.com/tensorflow/tensorflow/issues/36151#issuecomment-578001359

Categories

Resources