Ошибка при импорте tensorflow

I installed TensorFlow on my Windows Python 3.5 Anaconda environment
The validation was successful (with a warning)

(tensorflow) C:>python

Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 17:03:30) [MSC v.1900 64 bit (AMD64)] on win32

Type «help», «copyright», «credits» or «license» for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()

2017-10-04 11:06:13.569696: W C:tf_jenkinshomeworkspacerel-winMwindowsPY35tensorflowcoreplatformcpu_feature_guard.cc:45] The TensorFlow library wasn’t compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.

>>> print(sess.run(hello))

b’Hello, TensorFlow!’

However, when I attempt to import it into my python code

from __future__ import print_function, division
import numpy as np
import os
import matplotlib
import tensorflow as tf

I get this error

ImportError: No module named ‘tensorflow’

This is the location of the tensorflow package on my C drive

C:UsersmynameAnaconda2envstensorflowLibsite-packagestensorflow

When I go to Anaconda Navigator, it seems I have to choose either root, Python35, or Tensorflow. It looks like the Tensorflow environment includes Python35.

Anaconda Navigator launcher had to be reinstalled recently, possibly due to the Tensorflow installation. Maybe if there were another way to set the environment to Tensorflow within Anaconda /Spyder IDE other than the Navigator it might help

Method of installing tensorflow

conda create --name tensorflow python=3.5; 
pip install --ignore-installed --upgrade tensorflow 

I did try:
uninstalling and reinstalling protobuf, as suggesed by some blogs

I see another SO user asked the same question in March, received no reply

I’m trying to getting start with tensorflow with this manual https://www.tensorflow.org/install/install_windows all the installation complete successfully, i m using python 3.5.2 and latest version of pip, encountering this error, anyone explain me what should i do?

enter code here Traceback (most recent call last): File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpythonpywrap_tensorflow.py», line 18, in swig_import_helper return importlib.import_module(mname) File «C:UsersparthAppDataLocalProgramsPythonPython35libimport it__.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_unlo File «», line 666, in _load_unlocked File «», line 577, in module_from_spec File «», line 906, in create_mod File «», line 222, in _call_with_frames_r ImportError: DLL load failed: %1 is not a valid Win32 application. During handling of the above exception, another exception occurred: Traceback (most recent call last): File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpython__init__.py», line 66, in from tensorflow.python import pywrap_tensorflow File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpythonpywrap_tensorflow.py», line 21, in _pywrap_tensorflow = swig_import_helper() File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpythonpywrap_tensorflow.py», line 20, in swig_import_helper return importlib.import_module(‘_pywrap_tensorflow’) File «C:UsersparthAppDataLocalProgramsPythonPython35libimport it__.py», line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named ‘_pywrap_tensorflow’ During handling of the above exception, another exception occurred: Traceback (most recent call last): File «», line 1, in File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflow__init__.py», line 24, in from tensorflow.python import * File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpython__init__.py», line 72, in raise ImportError(msg) ImportError: Traceback (most recent call last): File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpythonpywrap_tensorflow.py», line 18, in swig_import_helper return importlib.import_module(mname) File «C:UsersparthAppDataLocalProgramsPythonPython35libimport it__.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_unlo File «», line 666, in _load_unlocked File «», line 577, in module_from_spec File «», line 906, in create_mod File «», line 222, in _call_with_frames_r ImportError: DLL load failed: %1 is not a valid Win32 application. During handling of the above exception, another exception occurred: Traceback (most recent call last): File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpython__init__.py», line 66, in from tensorflow.python import pywrap_tensorflow File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpythonpywrap_tensorflow.py», line 21, in _pywrap_tensorflow = swig_import_helper() File «C:UsersparthAppDataLocalProgramsPythonPython35libsite-p tensorflowpythonpywrap_tensorflow.py», line 20, in swig_import_helper return importlib.import_module(‘_pywrap_tensorflow’) File «C:UsersparthAppDataLocalProgramsPythonPython35libimport it__.py», line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named ‘_pywrap_tensorflow’ Failed to load the native TensorFlow runtime. See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3do arted/os_setup.md#import_error for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Closed

theerfan opened this issue

Sep 16, 2018

· 28 comments

Closed

Can’t import tensorflow

#22300

theerfan opened this issue

Sep 16, 2018

· 28 comments

Assignees

@gunan

Comments

@theerfan

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): just tried to import it.
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 x64
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): tried 1.10 down to 1.4, none worked, only cpu versions.
  • Python version: 3.7 (also tried with 3.6)
  • CPU model and memory: Intel core-i3 6100 — Skylake architecture [Tried on another system with the same OS and even more advanced cpu, still didn’t work.]
  • Exact command to reproduce: import tensorflow

Describe the problem

Can’t import. I double checked everything. From github and stackoverflow issues to whether or not my cpu supports avx instructions (it does) and even enabled intel virutalization option from boot. (Please consider these lines before tagging this as a duplicate.)

Source code / logs

Traceback (most recent call last):
File «FlowTest.py», line 15, in
import tensorflow
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflow_init_.py», line 22, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpython_init_.py», line 49, in
from tensorflow.python import pywrap_tensorflow
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow.py», line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 18, in swig_import_helper
fp, pathname, description = imp.find_module(‘_pywrap_tensorflow_internal’, [dirname(file)])
File «C:UsersthereAppDataLocalProgramsPythonPython37libimp.py», line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named ‘_pywrap_tensorflow_internal’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow.py», line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 20, in swig_import_helper
import _pywrap_tensorflow_internal
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.

@gunan

I am inclined to think this is an installation issue.
Could you check C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpython if it actually has `_pywrap_tensorflow_internal.dll» ?

@theerfan

I checked, it wasn’t there.

@gunan

Then there is our problem. What command did you use to install?

@theerfan

Trying pip install tensorflow didn’t work, then I found this which recommends using pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl, so I tried to get a little creative and changed the version to 1.10, 1.9 and so on, all resulting in the same problem.

@gunan

The URL you used is the macos URL, it definitely wont work.
Could you share the full output of pip install tensorflow using pastebin?

@theerfan

Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow

P.S: pastebin if necessary.

@gunan

Are you using 32 bit python by any chance?
Could you share the output of pip --version

@theerfan

No, I’m using 64 bit python.

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32

And as for pip,

pip 18.0 from c:usersthereappdatalocalprogramspythonpython37libsite-packagespip (python 3.7)

@gunan

Ah, it is because this is python 3.7.
The same package we have for python 3.6 should work fine.
Could you try

pip install --upgrade https://files.pythonhosted.org/packages/04/7e/a484776c73b1431f2b077e13801531e966113492552194fe721e6ef88d5d/tensorflow-1.10.1-cp36-cp36m-manylinux1_x86_64.whl

@theerfan

I tried.

tensorflow-1.10.1-cp36-cp36m-manylinux1_x86_64.whl is not a supported wheel on this platform.

P.S: sorry for my late responses. :D

@gunan

@theerfan

I did, but it opened another entire can of worms. (I have importlib listed in my pip packages so I’m not entirely sure what’s missing)

`Traceback (most recent call last):
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 14, in swig_import_helper
return importlib.import_module(mname)
File «C:UsersthereAppDataLocalProgramsPythonPython37libimportlib_init_.py», line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File «», line 1006, in _gcd_import
File «», line 983, in _find_and_load
File «», line 967, in _find_and_load_unlocked
File «», line 670, in _load_unlocked
File «», line 583, in module_from_spec
File «», line 1043, 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 «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow.py», line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 17, in
_pywrap_tensorflow_internal = swig_import_helper()
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 16, in swig_import_helper
return importlib.import_module(‘pywrap_tensorflow_internal’)
File «C:UsersthereAppDataLocalProgramsPythonPython37libimportlib_init
.py», line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named ‘_pywrap_tensorflow_internal’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «FlowTest.py», line 15, in
import tensorflow
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflow_init_.py», line 22, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpython_init_.py», line 49, in
from tensorflow.python import pywrap_tensorflow
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow.py», line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 14, in swig_import_helper
return importlib.import_module(mname)
File «C:UsersthereAppDataLocalProgramsPythonPython37libimportlib_init_.py», line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File «», line 1006, in _gcd_import
File «», line 983, in _find_and_load
File «», line 967, in _find_and_load_unlocked
File «», line 670, in _load_unlocked
File «», line 583, in module_from_spec
File «», line 1043, 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 «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow.py», line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 17, in
_pywrap_tensorflow_internal = swig_import_helper()
File «C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 16, in swig_import_helper
return importlib.import_module(‘pywrap_tensorflow_internal’)
File «C:UsersthereAppDataLocalProgramsPythonPython37libimportlib_init
.py», line 127, 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.`

@theerfan

@gunan

With python 3.7, the issue may be a duplicate of #20517

@theerfan

I did the same with Python 3.6 and it imports successfully, but now the script doesn’t run completely (I’m using the code used by google here
Specifically, this code:

import math
from IPython import display
from matplotlib import cm, gridspec, pyplot as plt
import numpy as np
import pandas as pd
import tensorflow as tf
from sklearn import metrics
from tensorflow.python.data import Dataset

tf.logging.set_verbosity(tf.logging.ERROR)
pd.options.display.max_rows = 15
pd.options.display.float_format = ‘{:.1f}’.format
california_housing_dataframe = pd.read_csv(«https://download.mlcc.google.com/mledu-datasets/california_housing_train.csv», sep=»,»)
california_housing_dataframe = california_housing_dataframe.reindex(
np.random.permutation(california_housing_dataframe.index))
california_housing_dataframe[«median_house_value»] /= 1000.0
first_feature = california_housing_dataframe[[«total_rooms»]]
feature_columns = [tf.feature_column.numeric_column(«total_rooms»)]
targets = california_housing_dataframe[«median_house_value»]
my_optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.0000001)
my_optimizer = tf.contrib.estimator.clip_gradients_by_norm(my_optimizer, 5.0)
linear_regressor = tf.estimator.LinearRegressor(
feature_columns=feature_columns,
optimizer=my_optimizer
)

def my_input_fn(features, targets, batch_size=1, shuffle=True, num_epochs=None):
features = {key:np.array(value) for key, value in dict(features).items()}
ds = Dataset.from_tensor_slices((features, targets))
ds = ds.batch(batch_size).repeat(num_epochs)
if shuffle:
ds = ds.shuffle(buffer_size=1000)

features, labels = ds.make_one_shot_iterator().get_next()
return features, labels

_ = linear_regressor.train(
input_fn = lambda:my_input_fn(first_feature, targets),
steps=100
)

prediction_input_fn = lambda: my_input_fn(first_feature, targets, num_epochs=1, shuffle=False)
predictions = linear_regressor.predict(input_fn=prediction_input_fn)
predictions = np.array([item[‘predictions’][0] for item in predictions])
mean_squared_error = metrics.mean_squared_error(predictions, targets)
root_mean_squared_error = math.sqrt(mean_squared_error)

and instead, gives me this error [Tried on both anaconda and outside of it, got the same result]
2018-09-26 19:52:12.039502: I T:srcgithubtensorflowtensorflowcoreplatformcpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

I even tried to install it from source so I could config it with my current cpu instructions, but I ran into a problem when I ran this command from powershell.
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
Gave
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: no such package '@gif_archive//': java.io.IOException: Error downloading [https://mirror.bazel.build/ufpr.dl.sourceforge.net/project/giflib/giflib-5.1.4.tar.gz, http://pilotfiber.dl.sourceforge.net/project/giflib/giflib-5.1.4.tar.gz] to C:/users/there/_bazel_there/5v74hkvm/external/gif_archive/giflib-5.1.4.tar.gz: All mirrors are down: [GET returned 403 Forbidden]

I even tried installing using wheels made by other developers which were compiled to use AVX2, but they also ran into issues and didn’t install.

@theerfan

@gunan

This message is not an error message, it just informs you that TF can run faster on your machine:

2018-09-26 19:52:12.039502: I T:srcgithubtensorflowtensorflowcoreplatformcpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

So if this is the only error you see, TF is running fine on your system.

About the URLs, I manually verified that all of them are accessible and online. It is probably some issue with your internet connection, or a firewall if you are behind one.

@aafreenart

I experienced this issue when I installed tensorflow using conda. Then I uninstalled tensorflow and installed it using pip3 command. The issue has been resolved.

@gptshubham595

help same issue
`ImportError Traceback (most recent call last)
C:ProgramDataAnaconda3libsite-packagestensorflowpythonpywrap_tensorflow_internal.py in swig_import_helper()
17 try:
—> 18 fp, pathname, description = imp.find_module(‘_pywrap_tensorflow_internal’, [dirname(file)])
19 except ImportError:

C:ProgramDataAnaconda3libimp.py in find_module(name, path)
296 else:
—> 297 raise ImportError(_ERR_MSG.format(name), name=name)
298

ImportError: No module named ‘_pywrap_tensorflow_internal’

During handling of the above exception, another exception occurred:

ModuleNotFoundError Traceback (most recent call last)
C:ProgramDataAnaconda3libsite-packagestensorflowpythonpywrap_tensorflow.py in ()
57
—> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import version

C:ProgramDataAnaconda3libsite-packagestensorflowpythonpywrap_tensorflow_internal.py in ()
27 return _mod
—> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper

C:ProgramDataAnaconda3libsite-packagestensorflowpythonpywrap_tensorflow_internal.py in swig_import_helper()
19 except ImportError:
—> 20 import _pywrap_tensorflow_internal
21 return _pywrap_tensorflow_internal

ModuleNotFoundError: No module named ‘_pywrap_tensorflow_internal’

During handling of the above exception, another exception occurred:
`

@khaliltalib277

Hello there,
I’m installing tensorflow on anaconda but I get the compiler error, please help me regarding this issue

ImportError Traceback (most recent call last)
~Anaconda3libsite-packagestensorflowpythonpywrap_tensorflow.py in
57
—> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import version

~Anaconda3libsite-packagestensorflowpythonpywrap_tensorflow_internal.py in
27 return _mod
—> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper

~Anaconda3libsite-packagestensorflowpythonpywrap_tensorflow_internal.py in swig_import_helper()
23 try:
—> 24 _mod = imp.load_module(‘_pywrap_tensorflow_internal’, fp, pathname, description)
25 finally:

~Anaconda3libimp.py in load_module(name, file, filename, details)
241 else:
—> 242 return load_dynamic(name, filename, file)
243 elif type_ == PKG_DIRECTORY:

~Anaconda3libimp.py in load_dynamic(name, path, file)
341 name=name, loader=loader, origin=path)
—> 342 return _load(spec)
343

ImportError: DLL load failed with error code -1073741795

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in
—-> 1 import tensorflow as tf
2 a= tf.constant(10)
3 b= tf.constant(10)
4 print(sess.run(a+b))

~Anaconda3libsite-packagestensorflow_init_.py in
22
23 # pylint: disable=g-bad-import-order
—> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25
26 from tensorflow._api.v1 import app

~Anaconda3libsite-packagestensorflowpython_init_.py in
47 import numpy as np
48
—> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers

~Anaconda3libsite-packagestensorflowpythonpywrap_tensorflow.py in
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.»»» % traceback.format_exc()
—> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
File «C:UserswAnaconda3libsite-packagestensorflowpythonpywrap_tensorflow.py», line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File «C:UserswAnaconda3libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File «C:UserswAnaconda3libsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 24, in swig_import_helper
_mod = imp.load_module(‘_pywrap_tensorflow_internal’, fp, pathname, description)
File «C:UserswAnaconda3libimp.py», line 242, in load_module
return load_dynamic(name, filename, file)
File «C:UserswAnaconda3libimp.py», line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed with error code -1073741795

@gunan

Looks like the issue was resolved?
@theerfan could you confirm?

@theerfan

Yeah, it was.
My apologies for forgetting to close the issue.

@azrnzhrl

Hi, could anyone help with the problem below? :( It’d be a great booster as im really just a newby. Similar or same problem may have shared with the community but im really new with this.

ImportError Traceback (most recent call last)
d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py in swig_import_helper()
13 try:
—> 14 return importlib.import_module(mname)
15 except ImportError:

d:pythonlibimportlib_init_.py in import_module(name, package)
125 level += 1
—> 126 return _bootstrap._gcd_import(name[level:], package, level)
127

d:pythonlibimportlib_bootstrap.py in _gcd_import(name, package, level)

d:pythonlibimportlib_bootstrap.py in find_and_load(name, import)

d:pythonlibimportlib_bootstrap.py in find_and_load_unlocked(name, import)

d:pythonlibimportlib_bootstrap.py in _load_unlocked(spec)

d:pythonlibimportlib_bootstrap.py in module_from_spec(spec)

d:pythonlibimportlib_bootstrap_external.py in create_module(self, spec)

d:pythonlibimportlib_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

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

During handling of the above exception, another exception occurred:

ModuleNotFoundError Traceback (most recent call last)
d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py in
57
—> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import version

d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py in
16 return importlib.import_module(‘_pywrap_tensorflow_internal’)
—> 17 _pywrap_tensorflow_internal = swig_import_helper()
18 del swig_import_helper

d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py in swig_import_helper()
15 except ImportError:
—> 16 return importlib.import_module(‘_pywrap_tensorflow_internal’)
17 _pywrap_tensorflow_internal = swig_import_helper()

d:pythonlibimportlib_init_.py in import_module(name, package)
125 level += 1
—> 126 return _bootstrap._gcd_import(name[level:], package, level)
127

ModuleNotFoundError: No module named ‘_pywrap_tensorflow_internal’

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in
4 import sys
5 import tarfile
—-> 6 import tensorflow as tf
7 import zipfile
8

d:pythonlibsite-packagestensorflow_init_.py in
20
21 # pylint: disable=g-bad-import-order
—> 22 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
23
24 try:

d:pythonlibsite-packagestensorflowpython_init_.py in
47 import numpy as np
48
—> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers

d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py in
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.»»» % traceback.format_exc()
—> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
File «d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 14, in swig_import_helper
return importlib.import_module(mname)
File «d:pythonlibimportlib_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:pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py», line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File «d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 17, in
_pywrap_tensorflow_internal = swig_import_helper()
File «d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 16, in swig_import_helper
return importlib.import_module(‘pywrap_tensorflow_internal’)
File «d:pythonlibimportlib_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.

@khaliltalib277

Now I am using tensorflow as a backend with Keras.

Best regards,

Khalil Ur Rehman
Student at Jiangsu University, China

________________________________
From: azrnzhrl <notifications@github.com>
Sent: Sunday, October 27, 2019 5:43:14 PM
To: tensorflow/tensorflow <tensorflow@noreply.github.com>
Cc: khaliltalib277 <khaliluaf@hotmail.com>; Comment <comment@noreply.github.com>
Subject: Re: [tensorflow/tensorflow] Can’t import tensorflow (#22300)

Hi, could anyone help with the problem below? :( It’d be a great booster as im really just a newby. Similar or same problem may have shared with the community but im really new with this.

ImportError Traceback (most recent call last)
d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py in swig_import_helper()
13 try:
—> 14 return importlib.import_module(mname)
15 except ImportError:

d:pythonlibimportlib_init_.py in import_module(name, package)
125 level += 1
—> 126 return _bootstrap._gcd_import(name[level:], package, level)
127

d:pythonlibimportlib_bootstrap.py in _gcd_import(name, package, level)

d:pythonlibimportlib_bootstrap.py in find_and_load(name, import)

d:pythonlibimportlib_bootstrap.py in find_and_load_unlocked(name, import)

d:pythonlibimportlib_bootstrap.py in _load_unlocked(spec)

d:pythonlibimportlib_bootstrap.py in module_from_spec(spec)

d:pythonlibimportlib_bootstrap_external.py in create_module(self, spec)

d:pythonlibimportlib_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

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

During handling of the above exception, another exception occurred:

ModuleNotFoundError Traceback (most recent call last)
d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py in
57
—> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import version

d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py in
16 return importlib.import_module(‘_pywrap_tensorflow_internal’)
—> 17 _pywrap_tensorflow_internal = swig_import_helper()
18 del swig_import_helper

d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py in swig_import_helper()
15 except ImportError:
—> 16 return importlib.import_module(‘_pywrap_tensorflow_internal’)
17 _pywrap_tensorflow_internal = swig_import_helper()

d:pythonlibimportlib_init_.py in import_module(name, package)
125 level += 1
—> 126 return _bootstrap._gcd_import(name[level:], package, level)
127

ModuleNotFoundError: No module named ‘_pywrap_tensorflow_internal’

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in
4 import sys
5 import tarfile
—-> 6 import tensorflow as tf
7 import zipfile
8

d:pythonlibsite-packagestensorflow_init_.py in
20
21 # pylint: disable=g-bad-import-order
—> 22 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
23
24 try:

d:pythonlibsite-packagestensorflowpython_init_.py in
47 import numpy as np
48
—> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers

d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py in
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.»»» % traceback.format_exc()
—> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
File «d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 14, in swig_import_helper
return importlib.import_module(mname)
File «d:pythonlibimportlib_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:pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py», line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File «d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 17, in
_pywrap_tensorflow_internal = swig_import_helper()
File «d:pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py», line 16, in swig_import_helper
return importlib.import_module(‘pywrap_tensorflow_internal’)
File «d:pythonlibimportlib_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.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#22300?email_source=notifications&email_token=AGK4XPYUZ7EHXE7WM4UL3D3QQVPDFA5CNFSM4FVLZ222YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECK2FSY#issuecomment-546677451>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGK4XP2CU5EHP2DMPJT5BLLQQVPDFANCNFSM4FVLZ22Q>.

@markhyro123

Traceback (most recent call last):
File «», line 1, in
File «C:UsersRobucaAnaconda3envsfinalthesislibsite-packagestensorflow_init_.py», line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File «C:UsersRobucaAnaconda3envsfinalthesislibsite-packagestensorflowpython_init_.py», line 59, in
from tensorflow.core.framework.graph_pb2 import *
File «C:UsersRobucaAnaconda3envsfinalthesislibsite-packagestensorflowcoreframeworkgraph_pb2.py», line 15, in
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File «C:UsersRobucaAnaconda3envsfinalthesislibsite-packagestensorflowcoreframeworknode_def_pb2.py», line 15, in
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File «C:UsersRobucaAnaconda3envsfinalthesislibsite-packagestensorflowcoreframeworkattr_value_pb2.py», line 15, in
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File «C:UsersRobucaAnaconda3envsfinalthesislibsite-packagestensorflowcoreframeworktensor_pb2.py», line 15, in
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File «C:UsersRobucaAnaconda3envsfinalthesislibsite-packagestensorflowcoreframeworkresource_handle_pb2.py», line 91, in
module = ‘tensorflow.core.framework.resource_handle_pb2’
TypeError: expected bytes, Descriptor found

plsss help me to fix this..
Im using tensorflow cpu, I dont have graphics card..

@SadiqKhanRaza

I had the same issue and for me the problem was in python and tensorflow version compatibility.
Tensorflow didn’t work with python 3.8 , So when I downgraded it to Python 3.5, It worked like a charm.

@ASLAMain

Traceback (most recent call last):
File «», line 1, in
File «C:UsersASLAMAppDataLocalProgramsPythonPython36libsite-packagestensorflow_init_.py», line 24, in
from tensorflow.python import *
File «C:UsersASLAMAppDataLocalProgramsPythonPython36libsite-packagestensorflowpython_init_.py», line 52, in
from tensorflow.core.framework.graph_pb2 import *
File «C:UsersASLAMAppDataLocalProgramsPythonPython36libsite-packagestensorflowcoreframeworkgraph_pb2.py», line 6, in
from google.protobuf import descriptor as _descriptor
File «C:UsersASLAMAppDataLocalProgramsPythonPython36libsite-packagesgoogleprotobufdescriptor.py», line 47, in
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.

pls help anyone

@mihaimaruseac

@tensorflow
tensorflow

locked as resolved and limited conversation to collaborators

Mar 21, 2020

In this Python tutorial, we will discuss the error “import error no module named TensorFlow. Here we’ll cover the reason related to this error using Python. And we’ll also cover the following topics:

  • Import error no module named tensorflow.compat.v1
  • Import error no module named ‘tensorflow.contrib’
  • Import error no module named tensorflow_hub
  • Import error no module named ‘tensorflow addons’
  • Import error no module named ‘tensorflow.python.eager’
  • In this section, we will discuss the error import error no module named TensorFlow in Python.
  • Basically, this error message comes when we do not import the TensorFlow library or we can say the TensorFlow library is not installed in our system.
  • If you have not installed the TensorFlow library in your system and still want to try importing the TensorFlow library in your program then it will raise an error message ‘no module named TensorFlow.

Example:

import tensorflow as tf

tens1 = tf.Variable([[67, 89],[23, 45]])
tens2 = tf.Variable([[94, 117],[189, 210]])
new_output= tf.add(tens1,tens2)
print(new_output)

In the above code, we have used the tf.add() function and within this function, we assigned the given tensors ‘tens1’ and ‘tens2’ as an argument.

Here is the Screenshot of the following given code.

Python import error no module named TensorFlow
import error no module named TensorFlow

Now let’s see the solution for this error:

Visual Code Studio

If you have installed Visual code Studio then it will use a pip environment and if you want to import some needed libraries then you have to install via command.

  • install TensorFlow using pip command

Syntax:

Here is the Syntax of the installation of the TensorFlow library

pip install TensorFlow

This Syntax will help you to resolve the error ‘no Module named TensorFlow’

Jupyter

If you have installed Jupyter notebook then use the Conda environment. To get detailed information regarding how to install the TensorFlow library in the Conda environment. You can refer to our detailed article TensorFlow in Python.

Also, check: TensorFlow Sparse Tensor

Import error no module named ‘tensorflow.contrib’

  • Here we are going to discuss the error import error no module named ‘TensorFlow.contrib’.
  • Basically, the contrib module is not available in TensorFlow version 2.0. This module contains contributed code and it is also a volatile code.
  • The possible reason behind this error is when the interpreter cannot locate the contrib ‘module’ in the library.
  • The latest version of TensorFlow 2.x has removed the session and contrib module from the TensorFlow library.

Reason: module ‘contrib’ is not working in version 2.x

Example:

import tensorflow.contrib

Here is the Screenshot of the following given code

import error no module named 'tensorflow.contrib'
import error no module named ‘TensorFlow.contrib’

In the following given code, we have just imported the ‘TensorFlow.contrib’ module but when we executed this command it displays the No module named ‘TensorFlow.contrib’. The possible reason is this module does not work in the latest version of TensorFlow 2.x.

Let’s discuss the solution to this error

  • First, uninstall the already installed version, if it is the latest version then reinstall it with the older version. To uninstall the tensorflow 2.x you can easily use the command pip uninstall TensorFlow.
  • Now to install older version of TensorFlow 1.x you can use below command
pip install tensorflow==1.15.0

Read: Python TensorFlow reduce_sum

Import error no module named tensorflow.compat.v1

  • In this section, we are going to discuss the error no module named tensorflow.compat.v1.
  • The possible reason behind this error is that compat.v1 modules are deprecated in Tensorflow version 1.12.0. This module will help the user to write the code in both TensorFlow versions.
  • This module does not support the 1.12 version, if you want to execute this module on your system then you have to install the latest or above the 1.12 version.

Example:

import error no module named tensorflow compat v1 in Python
import error no module named TensorFlow compat v1 in Python

Now we are going to use the updated version of TensorFlow for importing the TensorFlow.compat.v1 module in Python

To install the new version of TensorFlow in Conda prompt you can use the below command

conda install tensorflow==2.6
Solution of no module named tensorflow compat v1 in Python
Solution of no module named TensorFlow compat v1 in Python

As you can see in the Screenshot we have checked the version of TensorFlow it displays 2.6 latest version and also successfully imported the TensorFlow.compat.v1.

Also, check: Module ‘TensorFlow’ has no attribute ‘session’

Import error no module named ‘tensorflow_hub’

  • In this Program, we will discuss the error no module named ‘tensorflow_hub’ in Python.
  • Basically, this error message comes when the module ‘tensorflow_hub’ is not available in the TensorFlow library package.

Example:

Python import error no module named tensorflow hub
Python import error no module named TensorFlow hub

As you can see in the Screenshot it displays no module name ‘tensorflow_hub’ the reason behind this is we are using the older version of TensorFlow 1.14. In this version, the tensorflow_hub module is not working.

Let’s have a look at the Solution to this error

To solve this error you have to install the latest version of TensorFlow in your system. By default 2.7 is a stable version and to install the updated version of TensorFlow, you can use the below command. This command is used for conda prompt users.

conda install tensorflow==2.7

Screenshot

Solution of import error no module named tensorflow hub
Solution of import error no module named TensorFlow hub

In this Screenshot, you can see that we have installed the latest version of TensorFlow 2.7 and then import the tensorflow_hub module.

Read: TensorFlow Tensor to numpy

Import error no module named ‘tensorflow addons’

  • In this section, we will discuss the error no module named ‘tensorflow addons’ in Python.
  • Basically, the addon module is available in the latest TensorFlow version 2.7 but we have to update the ‘TensorFlow addons’ module. This module is not available in core Tensorflow and it also supports optimizers, metrics, and losses.

Screenshot

import error no module named tensorflow addons
import error no module named TensorFlow addons

As you can see in the output, it displays no module name ‘tensorflow_addons’. And the possible reason is that the ‘tensorflow_addons‘ module is available in TensorFlow latest version 2.7. But we have to update the ‘tensorflow_addons’ module.

Let’s have a look at the Solution to this error

To solve this error you have to install the older version of TensorFlow in your system. By default 2.7 is a stable version but this module only does not work in the latest version 2.x.

Output:

Solution of import error no module named tensorflow addons
Solution of import error no module named TensorFlow addons

To upgrade the ‘TensorFlow addons’ module you can easily use the below command

pip install tensorflow-addons

In the above code, we have imported the tensorflow_addons() module after upgrading the module.

Read: TensorFlow global average pooling

Import error no module named ‘tensorflow.python.eager’

  • Here we are going to discuss the error no module named ‘tensorflow.python.eager’ in Python.
  • When I was trying to import the ‘TensorFlow.python.eager’ module this error comes out in output. The reason behind that is the version of the TensorFlow library.

Let’s have a look at the Solution to this error

In this example, we have just imported the TensorFlow library and then checked the version by using the tf.__version__ command. After that, we have imported the ‘tensorflow.python.eager’ module. Once you will execute this code the output displays the module has been successfully imported.

Example:

import error no module named tensorflow python eager
import error no module named tensorflow python eager

Also, take a look at some more Python TensorFlow tutorials.

  • Binary Cross Entropy TensorFlow
  • Gradient descent optimizer TensorFlow
  • Python TensorFlow Placeholder
  • Convert list to tensor TensorFlow
  • Module ‘tensorflow’ has no attribute ‘div’
  • Module ‘tensorflow’ has no attribute ‘sparse_placeholder’

So, in this tutorial, we have solved the error “import error no module named TensorFlow“. Here we’ll cover the reason related to this error using Python. And we’ll also cover the following topics:

  • import error no module named tensorflow.compat.v1
  • import error no module named ‘tensorflow.contrib’
  • import error no module named tensorflow_hub
  • import error no module named ‘tensorflow addons’
  • import error no module named ‘tensorflow.python.eager’

Fewlines4Biju Bijay

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.

Problem

You have TensorFlow installed on your cluster.

When you try to import TensorFlow, it fails with an Invalid Syntax or import error.

Cause

The version of protobuf installed on your cluster is not compatible with your version of TensorFlow.

Solution

Use a cluster-scoped init script to install TensorFlow with matching versions of NumPy and protobuf.

  1. Create the init script.
    %python
    
    dbutils.fs.put("/databricks/<init-script-folder>/install-tensorflow.sh","""
    #!/bin/bash
    set -e
    /databricks/python/bin/python -V
    /databricks/python/bin/pip install tensorflow protobuf==3.17.3 numpy==1.15.0
    """, True)
  2. Install the init script that you just created as a cluster-scoped init script (AWS | Azure | GCP).
    You will need the full path to the location of the script (dbfs:/databricks/<init-script-folder>/install-tensorflow.sh).
  3. Restart the cluster after you have installed the init script.

Delete

Info

Uninstall all existing versions of NumPy before installing the init script on your cluster.

  • Ошибка при иммобилизации всей нижней конечности лестничными шинами
  • Ошибка при измерении сканворд
  • Ошибка при измерении давления автоматическим тонометром err cuf
  • Ошибка при измерении возникает если
  • Ошибка при изменении статуса задачи код ошибки 102 касперский