Failed to load the native TensorFlow runtime.? - python

I am trying to import tensorflow but every time i do import tensorflow i get this annoying error it says
"Failed to load the native TensorFlow runtime." i have looked my error into
https://www.tensorflow.org/install/errors but i did not find my answer yet i probably missed it But....
My error:
ImportError: Traceback (most recent call last):
File "C:\ProgramData\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.
I used pip install tensorflow also if i do pip install tensorflow in my console i get "Requirement already satisfied: tensorflow in c:\programdata\anaconda3\lib\site-packages (2.3.1)"
but when i do import tensorflow i get my Import Error
also my pip version is 20.2.4

you are using Anaconda it will support
Tensorflow == 2.1.0
create a new environment for tensorflow
conda create -n tf tensorflow
activate tf

I figured how to do it for me i just needed to do:
pip install tensorflow==1.15

Related

realtime object detection No module named 'tensorflow.compat.v1'

I am following a Real time object detection on https://automaticaddison.com/real-time-object-recognition-using-a-webcam-and-deep-learning/#top and I have hit a road block I followed all the instructions and checked for any errors but still got this error
(I am using windows)
Traceback (most recent call last): File "object_detection_test.py",
line 15, in <module>
from utils import label_map_util File "C:\Users\1rock\Documents\TensorFlow\models\research\object_detection\utils\label_map_util.py",
line 27, in <module>
import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'
I used pip install --ignore-installed --upgrade tensorflow==1.9 just what the link above said and whilst running I got these packages and their versions and an error hope it would be relevant to the question
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ipywidgets 7.6.0 requires jupyterlab-widgets>=1.0.0, which is not installed.
Successfully installed absl-py-0.11.0 astor-0.8.1 gast-0.4.0 grpcio-1.34.0 importlib-metadata-3.3.0 markdown-3.3.3 numpy-1.19.4 protobuf-3.14.0 setuptools-51.0.0.post20201207 six-1.15.0 tensorboard-1.9.0 tensorflow-1.9.0 termcolor-1.1.0 typing-extensions-3.7.4.3 werkzeug-1.0.1 wheel-0.36.2 zipp-3.4.0
I used pip install --ignore-installed --upgrade tensorflow==1.9
line 27, in
import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'
TF 1.9 and earlier do not have compat module. To use it you need TF 1.10+. Its better to use conda install everywhere possible with conda virtual enviroment.
Also since you are using tensorflow models make sure you has corresponding version of repository, for example latest TF1.x version located here

Failed to load the native TensorFlow runtime?

I am getting below error while doing from keras.models import Sequential
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py
in
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\joe\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 64, in
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.
Here is the result of pip freeze
alabaster==0.7.12
anaconda-client==1.7.2
anaconda-navigator==1.9.12
anaconda-project==0.8.3
....
conda==4.9.2
conda-build==3.18.11
Keras==2.3.1
Keras-Applications # file:///tmp/build/80754af9/keras-applications_1594366238411/work
Keras-Preprocessing==1.1.2
tensorflow==2.3.1
tensorflow-estimator==2.3.0
Per answer at Failed to load the native TensorFlow runtime. Python 3.5.2 I tried below
conda create -n gpu_env tensorflow-gpu
conda activate gpu_env
Which gives below result on pip freeze
jupyter-core==4.6.3
Keras-Applications # file:///tmp/build/80754af9/keras-applications_1594366238411/work
Keras-Preprocessing==1.1.0
tensorflow==2.1.0
tensorflow-estimator==2.1.0
termcolor==1.1.0
But when I open the jupyter notebook and execute the program get the same error.Not sure what's the issue here ?
I was able to solve this with
pip uninstall tensorflow
pip install tensorflow==1.15
you are using Anaconda it will support
Tensorflow == 2.1.0
Keras == 2.3.1
create a new environment for tensorflow
conda create -n tf tensorflow
activate tf
then install keras
pip install keras==2.3.1

no module named tensorflow.contrib

I have this problem when I import tensorflow.contrib.slim
import tensorflow.contrib.slim as slim
i get this error message
Traceback (most recent call last):
File "/home/toshiba/PFE/DocFace-master/src/tflib.py", line 28, in <module>
import tensorflow.contrib.slim as slim
ModuleNotFoundError: No module named 'tensorflow.contrib'
tensorflow is correctly installed and i found some solutions that said that the file name is tensorflow so it causes the problem but that is not the case in here
You probably have TensorFlow version 2.* installed, but tf.contrib.slim is TensorFlow 1.15 code. You can check here how to migrate your existing code to tensorflow 2.*.
If you instead want to keep your code, you can downgrade to TensorFlow by typing pip install tensorflow==1.15 into your command-line to downgrade to TensorFlow 1.15.
tf.contrib is not supported in TensorFlow 2.x, but you can exploit TensorFlow-Slim avoiding to downgrade TensorFlow.
You have to install TensforFlow-Slim as pip install --upgrade tf_slim and then substitute import tensorflow.contrib.slim as slim in your code with import tf_slim as slim

protobuf successfully installed but cannot import

I installed tensorflow 1.13.1 and protobuf 3.6.1. successfully. But when I tried to import protobuf 3.6.1, an error occurs. I used python 3.6.0
Error is given below:
import protobuf
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'protobuf'
because of this i cannot import tensorflow
As discussed in comments, working with pip to get tensorflow running on this particular system turned out to be complicated. Instead, we went with Anaconda installation:
conda create -n yourenvname tensorflow
To import protobuf:
import google.protobuf

Tensorflow error : DLL load failed: The specified procedure could not be found

I tried to install tensorflow cpu using pip in my windows8.1 64bit python3.6.0
using pip install tensorflow
but it gives me this error:
Traceback (most recent call last): File "C:\Users\Laitooo
San\Desktop\tf.py", line 1, in <module>
import tensorflow as tf File "C:\Users\Laitooo San\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py",
line 24, in <module>
from tensorflow.python import * File "C:\Users\Laitooo San\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\Laitooo
San\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\Laitooo
San\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 downloaded python36.dll and made sure all other .dll is there and install Microsoft visual c++ 2015
I also uninstalled tensorflow and installed another version several times but without any result.
I had this error as well, and was able to resolve it by downgrading protobuf from 3.6.1 to 3.6.0:
pip install protobuf==3.6.0
windows 10
python 3.6
Cuda 9.0
cudnn-9.0-windows10-x64-v7.6.3.30
tensorflow-gpu == 1.12.0
keras == 2.2.4
problem was:
ImportError: DLL load failed: The specified procedure could not be
found.
solved with:
pip install protobuf==3.6.0
There is a similar issue on Github:
Tensorflow issue
Problem should be resolved if you install the wheel file provided in one of the answers. You can find the wheel file here.
Wheel file
You can install the wheel file with pip. First change the current directory to install location. Then,
pip install tensorflow-1.6.0-cp36-cp36m-win_amd64.whl
All official tensorflow binaries since 1.6 were made with AVX, rendering older CPUs unsupported.
In order to install recent tensorflow versions on an older CPU you can simply install tensorflow from a non-avx built wheel ( you can find some here)
pip install <path to the downloaded .whl file>
its the problem with python=3.6.0
Upgrade to any higher versions of python 3.6
Updating from python 3.6.0 to python 3.6.4 fixed this issue for me.
I got this (unhelpful) error after installing on python 3.7. Turns out I had not installed cuDNN, the neural network package. After that, it runs without issue.
I had the same problem.
I made it work by uninstalling scipy and then reinstalling.
First uninstall seaborn.
pip uninstall seaborn
then uninstall scipy.
pip uninstall scipy.
After that install both scipy and seaborn.
pip install scipy,
pip install seaborn
I hope it helps

Categories