import tensorflow throws ImportError: DLL load failed - python

i have installed tensorflow in virtualenv as well as regular system install and added all the required directories to Path
i am using python 3.6.0
installed tensorflow cpu only
import tensorflow as tf
Throws:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\env\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-
import
File "C:\env\lib\site-packages\tensorflow\python\__init__.py", line 59, in
<module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\env\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line
6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\env\lib\site-packages\google\protobuf\descriptor.py", line 47, in
<module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.

Please upgrade your Python Version from 3.6.0 to 3.6.1 and your issue will be resolved.
For more information, please refer Github Issue 1 and Github Issue 2

Related

ModuleNotFoundError: No module named 'tensorflow.core'

My python version is python3.8.8.
I installed tensorflow2.7 on a linux server.
And when I import tensorflow.keras. It shows error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 41, in <module>
from tensorflow.python.eager import context
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/eager/context.py", line 47, in <module>
from tensorflow.python.util.deprecation import deprecated
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/util/deprecation.py", line 32, in <module>
from tensorflow.tools.docs import doc_controls
ModuleNotFoundError: No module named 'tensorflow.tools'
I tried to uninstall tensorflow2.7 and install older version tensorflow2.2
the error becomes:
Traceback (most recent call last):
File "cnn_mnist1.py", line 7, in <module>
import tensorflow.keras as keras
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 53, in <module>
from tensorflow.core.framework.graph_pb2 import *
ModuleNotFoundError: No module named 'tensorflow.core'
I am confused about why I need to import tensorflow.tools or tensorflow.core when I only want to import tensorflow.keras?
Someone told me I should build a virtual environment to deal with it. But I would like to know why tensorflow.tools and tensorflow.core are missing?
Besides, when I install tensorflow using pip. The installation always stops(see below). Several minutes later I have to terminate it. Does it cause some packages missing?
Thank you!
Tensorflow 2.7 requires to install keras individually with pip install keras an then you can use keras like before the release: from tensorflow import keras.

tensorflow 2.3.1 ImportError: DLL load failed: The specified module could not be found

I've read multiple posts regarding this problem however no luck fixing it.
I am using tensorflow-cpu version 2.3.1, Python 3.7.3. I have downloaded using pip. I keep on getting ImportError and not sure what to do from here, most post talks about tensorflow-gpu version.
Here is my full Traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\haneu\AppData\Local\Continuum\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.
After uninstalling all Visual Studio previous version and re-installing new one, it got rid of ImportError thanks to Tensorflow Error: ImportError: DLL load failed: The specified module could not be found
However after that I kept on getting ModuleNotFoundError everytime I've got this, uninstalled that module and re-installed it. My guess is that there were versions not compatible with each other. But anyways it had fixed my problem.

Tensorflow Error: ImportError: DLL load failed: The specified module could not be found

I've looked through previous answers to similar questions but couldn't find the answer that worked for me.
I've worked with TensorFlow for a long time. Currently trying out Yolov4 which has a requirement to use Tensorflow version 2.3.0, so I decided to install that one.
Anaconda's latest release is 2.1.0 that works great on my computer. So since that was not enough, I created a new environment and installed Tensorflow with pip install tensorflow-gpu which installs version 2.3.0 seemingly without errors.
Then for the import tensorflow as tf I get this error. Any ideas what to try to resolve this?
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\mazat\Anaconda3\envs\tf23\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.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\mazat\Anaconda3\envs\tf23\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.
Looks like the problem was the old version of Redistributable for Visual Studio.
With the new version from here, it seems to work thus far!
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
I had a similar problem and update Visual Studio (https://visualstudio.microsoft.com/pt-br/downloads/) worked for me.

Error when executing Python inference.py script

I am working on designing a chatbot using tensorflow in python, I have windows 10 (64 bit) installed with python version 3.6.0.
when trying to execute Python inference.py I got the following error
Traceback (most recent call last):
File "inference.py", line 9, in
from nmt import nmt
File "C:\Users\Ali\Documents\Visual Studio 2017\Projects\SequenceToSequenceModel\nmt-chatbot/nmt\nmt\nmt.py", line 26, in
import tensorflow as tf
File "C:\Users\Ali\AppData\Roaming\Python\Python36\site-packages\tensorflow__init__.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Ali\AppData\Roaming\Python\Python36\site-packages\tensorflow\python__init__.py", line 59, in
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Ali\AppData\Roaming\Python\Python36\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in
from google.protobuf import descriptor as _descriptor
File "c:\users\ali\appdata\roaming\python\python36\site-packages\google\protobuf\descriptor.py", line 47, in
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
I appreciate any help you provide.

tensorflow import problem although tensorflow is installed using pip

Hi I am new to tensorflow running pything 3.6 and installed tensorflow using pip. I have encountered a problem where when I import it in python it gives me an error:
File "<stdin>", line 1, in <module>
File "C:\Users\Usman Ali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Usman Ali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Usman Ali\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\Usman Ali\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
I researched and found solution that it might be Visual C++ Reditributable needs to be installed but I have installed it restarted but still same error. Any solution to this problem.

Categories

Resources