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
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
Comments
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.
I am inclined to think this is an installation issue.
Could you check C:UsersthereAppDataLocalProgramsPythonPython37libsite-packagestensorflowpython if it actually has `_pywrap_tensorflow_internal.dll» ?
I checked, it wasn’t there.
Then there is our problem. What command did you use to install?
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.
The URL you used is the macos URL, it definitely wont work.
Could you share the full output of pip install tensorflow using pastebin?
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.
Are you using 32 bit python by any chance?
Could you share the output of pip --version
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)
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
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. 😀
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.`
With python 3.7, the issue may be a duplicate of #20517
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 Datasettf.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.
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.
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.
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:
`
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
Looks like the issue was resolved?
@theerfan could you confirm?
Yeah, it was.
My apologies for forgetting to close the issue.
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.
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>.
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..
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.
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
tensorflow
locked as resolved and limited conversation to collaborators
Mar 21, 2020
I installed tensorflow using the following command.
pip install tensorflow
I am running a simple program which is
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly
print(node1, node2)
I am getting the following error on running the program.
Traceback (most recent call last):
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:Program Files (x86)Pythonlibimportlib__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 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", 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:Program Files (x86)Pythonlibsite-
packagestensorflowpythonpywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:Program Files (x86)Pythonlibimportlib__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 "first.py", line 1, in <module>
import tensorflow as tf
File "C:Program Files (x86)Pythonlibsite-packagestensorflow__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpython__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:Program Files (x86)Pythonlibimportlib__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 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", 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:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:Program Files (x86)Pythonlibimportlib__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 have updated the pip and am running the program on python 3.5
I installed tensorflow using the following command.
pip install tensorflow
I am running a simple program which is
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly
print(node1, node2)
I am getting the following error on running the program.
Traceback (most recent call last):
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:Program Files (x86)Pythonlibimportlib__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 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", 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:Program Files (x86)Pythonlibsite-
packagestensorflowpythonpywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:Program Files (x86)Pythonlibimportlib__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 "first.py", line 1, in <module>
import tensorflow as tf
File "C:Program Files (x86)Pythonlibsite-packagestensorflow__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpython__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:Program Files (x86)Pythonlibimportlib__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 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", 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:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:Program Files (x86)Pythonlibsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:Program Files (x86)Pythonlibimportlib__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 have updated the pip and am running the program on python 3.5
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.

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

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:

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

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:

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

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

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:

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:

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’

Python is one of the most popular languages in the United States of America. I have been working with Python for a long time and I have expertise in working with various libraries on Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… I have experience in working with various clients in countries like United States, Canada, United Kingdom, Australia, New Zealand, etc. Check out my profile.
TensorFlow uses GitHub issues,
Stack Overflow and
TensorFlow Forum
to track, document, and discuss build and installation problems.
The following list links error messages to a solution or discussion. If you find
an installation or build problem that is not listed, please search the GitHub
issues and Stack Overflow. If you still can’t find the error message, ask a new
question on Stack Overflow with the tensorflow tag.
| GitHub issue or Stack Overflow | Error Message |
|---|---|
| 38896424 31058 |
«No matching distribution found for tensorflow»: Pip can’t find a TensorFlow package compatible with your system. Check the system requirements and Python version |
| 22390 |
Unzipping simple_console_for_windows.zip to create runfiles tree...
[./bazel-bin/tensorflow/tools/pip_package/simple_console_for_windows.zip]
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of ./bazel-bin/tensorflow/tools/pip_package/simple_console_for_windows.zip or
./bazel-bin/tensorflow/tools/pip_package/simple_console_for_windows.zip.zip, and cannot find ./bazel-bin/tensorflow/tools/pip_package/simple_console_for_windows.zip.ZIP, period.
|
| 36159194 |
ImportError: libcudart.so.Version: cannot open shared object file: No such file or directory |
| 41991101 |
ImportError: libcudnn.Version: cannot open shared object file: No such file or directory |
| 36371137 |
libprotobuf ERROR google/protobuf/src/google/protobuf/io/coded_stream.cc:207] A protocol message was rejected because it was too big (more than 67108864 bytes). To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h. |
| 35252888 |
Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory; please exit the tensorflow source tree, and relaunch your python interpreter from there. |
| 33623453 |
IOError: [Errno 2] No such file or directory: '/tmp/pip-o6Tpui-build/setup.py' |
| 42006320 |
ImportError: Traceback (most recent call last): File ".../tensorflow/core/framework/graph_pb2.py", line 6, in from google.protobuf import descriptor as _descriptor ImportError: cannot import name 'descriptor' |
| 35190574 |
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed |
| 42009190 |
Installing collected packages: setuptools, protobuf, wheel, numpy, tensorflow Found existing installation: setuptools 1.1.6 Uninstalling setuptools-1.1.6: Exception: ... [Errno 1] Operation not permitted: '/tmp/pip-a1DXRT-uninstall/.../lib/python/_markerlib' |
| 36933958 |
... Installing collected packages: setuptools, protobuf, wheel, numpy, tensorflow Found existing installation: setuptools 1.1.6 Uninstalling setuptools-1.1.6: Exception: ... [Errno 1] Operation not permitted: '/tmp/pip-a1DXRT-uninstall/System/Library/Frameworks/Python.framework/ Versions/2.7/Extras/lib/python/_markerlib' |
| 42006320 |
ImportError: Traceback (most recent call last): File ".../tensorflow/core/framework/graph_pb2.py", line 6, in from google.protobuf import descriptor as _descriptor ImportError: cannot import name 'descriptor' |
| 33623453 |
IOError: [Errno 2] No such file or directory: '/tmp/pip-o6Tpui-build/setup.py' |
| 35190574 |
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed |
| 42009190 |
Installing collected packages: setuptools, protobuf, wheel, numpy, tensorflow Found existing installation: setuptools 1.1.6 Uninstalling setuptools-1.1.6: Exception: ... [Errno 1] Operation not permitted: '/tmp/pip-a1DXRT-uninstall/.../lib/python/_markerlib' |
| 33622019 |
ImportError: No module named copyreg |
| 37810228 | During a pip install operation, the system returns:
OSError: [Errno 1] Operation not permitted |
| 33622842 | An import tensorflow statement triggers an error such as the following: Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/tensorflow/__init__.py",
line 4, in
from tensorflow.python import *
...
File "/usr/local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py",
line 22, in
serialized_pb=_b('n,tensorflow/core/framework/tensor_shape.protox12ntensorflow"dnx10TensorShapeProtox12-nx03x64imx18x02
x03(x0bx32
.tensorflow.TensorShapeProto.Dimx1a!nx03x44imx12x0cnx04sizex18x01
x01(x03x12x0cnx04namex18x02 x01(tbx06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
|
| 42075397 | A pip install command triggers the following error:
...
You have not agreed to the Xcode license agreements, please run
'xcodebuild -license' (for user-level acceptance) or
'sudo xcodebuild -license' (for system-wide acceptance) from within a
Terminal window to review and agree to the Xcode license agreements.
...
File "numpy/core/setup.py", line 653, in get_mathlib_info
raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
|
| 41007279 |
[...stream_executordso_loader.cc] Couldn't open CUDA library nvcuda.dll |
| 41007279 |
[...stream_executorcudacuda_dnn.cc] Unable to load cuDNN DSO |
| 42006320 |
ImportError: Traceback (most recent call last): File "...tensorflowcoreframeworkgraph_pb2.py", line 6, in from google.protobuf import descriptor as _descriptor ImportError: cannot import name 'descriptor' |
| 42011070 |
No module named "pywrap_tensorflow" |
| 42217532 |
OpKernel ('op: "BestSplits" device_type: "CPU"') for unknown op: BestSplits
|
| 43134753 |
The TensorFlow library wasn't compiled to use SSE instructions |
| 38896424 |
Could not find a version that satisfies the requirement tensorflow |
| 42006320 |
ImportError: Traceback (most recent call last): File ".../tensorflow/core/framework/graph_pb2.py", line 6, in from google.protobuf import descriptor as _descriptor ImportError: cannot import name 'descriptor' |
| 33623453 |
IOError: [Errno 2] No such file or directory: '/tmp/pip-o6Tpui-build/setup.py' |
| 35190574 |
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed |
| 42009190 |
Installing collected packages: setuptools, protobuf, wheel, numpy, tensorflow Found existing installation: setuptools 1.1.6 Uninstalling setuptools-1.1.6: Exception: ... [Errno 1] Operation not permitted: '/tmp/pip-a1DXRT-uninstall/.../lib/python/_markerlib' |
| 33622019 |
ImportError: No module named copyreg |
| 37810228 | During a pip install operation, the system returns:
OSError: [Errno 1] Operation not permitted |
| 33622842 | An import tensorflow statement triggers an error such as the following: Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/tensorflow/__init__.py",
line 4, in
from tensorflow.python import *
...
File "/usr/local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py",
line 22, in
serialized_pb=_b('n,tensorflow/core/framework/tensor_shape.protox12ntensorflow"dnx10TensorShapeProtox12-nx03x64imx18x02
x03(x0bx32
.tensorflow.TensorShapeProto.Dimx1a!nx03x44imx12x0cnx04sizex18x01
x01(x03x12x0cnx04namex18x02 x01(tbx06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
|
| 41293077 |
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. |
| 42013316 |
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory |
| 42013316 |
ImportError: libcudnn.5: cannot open shared object file: No such file or directory |
| 35953210 | Invoking `python` or `ipython` generates the following error:
ImportError: cannot import name pywrap_tensorflow |
| 45276830 |
external/local_config_cc/BUILD:50:5: in apple_cc_toolchain rule @local_config_cc//:cc-compiler-darwin_x86_64: Xcode version must be specified to use an Apple CROSSTOOL. |
| 47080760 |
undefined reference to `cublasGemmEx@libcublas.so.9.0' |
| 22512 |
ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_internal' |
| 22512, 22794 |
ImportError: DLL load failed: The specified module could not be found. |
| 24835 |
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: [long path name] |
Python is known for its versatile syntax and English-like keywords. With thousands of modules, you can do data visualization, data processing and even deploy machine learning models. There are many known machine learning models published which help you, namely, Keras, Sklearn, Tensorflow, and PyTorch. Although, while using Tensorflow, you can encounter a No Module named Tensorflow error while running your first program.
No Module Named Tensorflow Error is a known error that arises when the Python Environment is unable to fetch TensorFlow files in site-packages. There are two main reasons for this error to appear, either you have not installed the TensorFlow external module or you are working on a different python environment that doesn’t have Tensorflow. There are several easy ways to fix this error which are mentioned later in this post. Let’s understand the root cause of the error before jumping on the solution.

When a module is absent from the external site-library of the environment, the Python interpreter throws ModuleNotFoundError No Module Named Tensorflow. This error arises most of the time on low-end devices because TensorFlow requires proper setup of the c++ path and other requirements. Most of the time, this error is solved by using the pip install method. But if you have multiple Python versions installed, then you’ll definitely face this error.
Why do I get No Module Named Tensorflow Error?
There is no other reason for the No Module Named Tensorflow error other than missing module files. The main problem arises when you’re using multiple python versions and their virtual environment. Keep in mind that, Anaconda, PyCharm, Jupyter, and Spyder have their own virtual environment and it’s tricky to install modules in that environment.
Causes of No Module Named Tensorflow Error
There are some known causes of this ModuleNotFoundError. As Python lets you handle these errors easily, you can debug them quickly. Following are the cause of the No Module Tensorflow error –
Module Not Installed
If you haven’t installed TensorFlow yet and tried importing TensorFlow in code, then it’ll throw this error. Modules are managed by ‘pip’ which is a package management system for your python. Most of the time, the users forget to tick Add Python to the PATH option while installing it. This creates problems in managing the modules.
Supporting Module Not Installed
Tensorflow has many other supporting modules like numpy, scipy, jupyter, matplotlib, pillow, and scikit-learn. If any of these modules is absent, then it’ll throw an error. Make sure that these modules exist in your library.
Moreover, there are other supporting TensorFlow modules like, tensorflow-addons, tensorflow.contrib which might be absent from your library leading to this error.
Tip: To check which libraries are installed in your environment, enter pip list on your console.
Working on Different Virtual Environment
Virtual Environment: Method by which you isolate your working Python environment from the globally installed Python. This environment has its own installation directories and doesn’t share the libraries from globally installed Python.
Many of the code editors in Windows come with their own virtual environment. Each of these environments acts independently to global python installation and is started with blank external modules. Many times, you install a module but it’s installed on global python, not the python from your virtual environment. This can lead to ModuleNotFoundError No Module named Tensorflow in the code execution.
Code editors namely, Anaconda, Jupyter, and Spyder have their own virtual environment. If you have a similar case, head over to the corresponding solution for each code editor.
Solutions for No Module Named Tensorflow
Following are the solutions for this error in each code editor and OS –
Windows

In Windows, the path-related issues harras the programmers all the time. As you have limited functionality over the terminal, you’re constantly facing with ModuleNotFoundError error. To install TensorFlow in your Windows, make sure you follow these steps –
- Uninstall existing python versions to avoid any conflicts.
- Go to Python.org and install the Python setup. Make sure you install the 64-bit version. Unfortunately, Tensorflow is not supported in 32 bit systems.
- Open the installer and select the “Add Python x.x to your PATH” option. This will ensure, that python executes from the path.
- After installing, open the command terminal or PowerShell and enter the command
pip install tensorflowin it. - Wait for it to finish the installation and run your python file by command
python file.py
Linux
In Linux, it’s relatively easier to install TensorFlow. First of all, check if you are working on a virtual environment by a command which python. This command will return the path of python which you’re going to execute. If you are in a virtual environment, either leave the environment directory or enter the command deactivate to deactivate the virtual environment.
Note: Please do not try to uninstall python in Linux as it’ll interfere with your GDM (Graphical Display Manager). Instead, install a new version and then create your own virtual environment.
Follow these steps to install Tensorflow in Linux –
sudo pip3 install tensorflow
Mac
In Mac, No Module named Tensorflow is a persistent error because of environment errors. If you are working on your virtual environment, you need to deactivate and activate it again. Then use the pip list command to check if the TensorFlow module exists in your library. If not, then use the pip3 install tensorflow to install TensorFlow.
Anaconda

If you’re using Anaconda and you face no module named Tensorflow error, then you probably haven’t installed TensorFlow in the conda environment. As anaconda has a different environment than your default python environment, you need to install TensorFlow in it. To do it follow these steps –
- Open Anaconda Prompt on your computer.
- Enter the command
conda install tensorflowin it. - Wait for the installation to complete and restart the conda shell and run your program.
Jupyter
If you’ve installed Juptyter Notebook from Anaconda, it’ll use a conda environment. By default, the libraries in this environment need to be installed via command. To do the same, open your Conda Prompt and enter the command conda install tensorflow. This will ensure that your Juptyer Notebook has TensorFlow in it.
If your Jupyter is not installed via Anaconda, then use the pip install tensorflow to install the TensorFlow module. This will resolve the error ModuleNotFoundError No module named Tensorflow instantly.
Spyder
Spyder is installed via Anaconda which operates an Anaconda environment. Simply use the command conda install tensorflow in your Anaconda Prompt to install TensorFlow.
PyCharm
PyCharm is a special application that operates in its own virtual environment. Due to the unavailability of the TensorFlow error, you can face the no module found error. Follow these steps to install TensorFlow –
- Press Settings and select the Project Interpreter tab under projects.
- Now enter Tensorflow in the box and install it.
- After installing the package, your error will be resolved.
Supporting ModuleNotFoundError for Tensorflow
Tensorflow has many addons which come in handy to avoid writing long code. These addons and contributions are added separately in other packages and combine with the original TensorFlow module. Following are the examples of ModuleNotFoundError –
No module named ‘tensorflow.contrib’
Unfortunately, the contrib module in TensorFlow is not included in version 2.0. If you still want to use the contrib module, you’ll have to install the previous version of TensorFlow. Follow these steps –
pip uninstall tensorflow pip install tensorflow==1.13.2
No module named ‘tensorflow_addons’
Use pip install tensorflow-addons to install the addons for TensorFlow.
No Module Named Tensorflow Still Not Resolved?
If you’ve tried all the methods and were still not able to solve the issue then, there might be some hardware limitations. Tensorflow requires Python 3.5-3.7, 64-bit system, and pip>=19.0. If you’re unable to fulfill these hardware + software requirements, then don’t worry, we still have a solution for you!
Google released a free product named ‘Colab‘ in 2018. Colab allows you to run and test machine learning models online. To explain more, it’s a replica of the jupyter notebook with all modules installed. To use Tensorflow in Google Colab follow these steps –
- Sign in to your Google account.
- Open Colab in your browser.
- Create a new Jupyter Notebook. (This notebook will be saved in your google drive).
- Type your code and run it.

Colab has many libraries like TensorFlow, numpy, pandas, etc pre-installed in its shell. Make sure you make good use of it.
Tip: Do not use Colab to store/process peer-to-peer files. This may result in a ban!
See Also
Conclusion
Tensor flow has a flexible architecture. The easy deployment of the code makes it special in nature. However, we have to be very careful before using it. Any small syntax error can result in incorrect importing of the library.
The “ModuleNotFoundError: No module named ‘tensorflow’” error in Python shows that Python cannot find the module ‘tensorflow’ that is imported in your code or some packages your code imports. This tutorial will show you how to fix the error by installing ‘tensorflow’ in your environment.
When you run your Python code, the Python runtime will look for all the packages or modules you import to your code and their dependencies. If the runtime cannot find a module, it will throw a ModuleNotFoundError. The error “ModuleNotFoundError: No module named ‘tensorflow’” show that Python cannot find ‘tensorflow’ in your environment, so you need to install it to run your code correctly. Here I have an example code that imports ‘tensorflow’ and prints its version. You will get the error if you run this code in a Python environment without ‘tensorflow’ installed.
Example code:
import tensorflow as tf
print("Tensorflow version:", tf.__version__)
Output:
Traceback (most recent call last):
File "main.py", line 1, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
How to solve the error?
Method 1: Install tensorflow directly with pip
Pip is the package installer for Python that comes with Python when you install Python on your machine. You can check the version of pip by the following command in your terminal of Linux/MacOS or the Command prompt of Windows.
pip --version
Output:
pip 21.1.3 from <the path where pip installed on your machine>
To install ‘tensorflow’ using pip, you can easily run this command.
pip install tensorflow
You can also specify the ‘tensorflow’ version that you want to install like this.
pip install tensorflow==2.10.0
After successfully installing ‘tensorflow’, you can use it in your code as you want.
Example code:
import tensorflow as tf
print("Tensorflow version:", tf.__version__)
Output:
Tensorflow version: 2.10.0
Method 2: Install tensorflow in a python virtual environment
It is recommended to install the packages that you need for different projects in different environments because you may want to use different versions of a package in your projects. Using different environments helps to keep the packages not conflict with each other. You can create and activate a virtual environment by the following steps.
- Step 1: Install virtualenv package
pip install virtualenv
- Step 2: Create the environment folder where the packages will be installed
python -m venv env
- Step 3: Activate the environment
On Linux/MacOS:
source env/bin/activate
On Windows:
cd env/Scripts
activate.bat
Step 2 will create an environment folder name env in the directory where you run the command. After activating your environment, you can normally install ‘tensorflow’ using the pip command:
pip install tensorflow
Method 3: Install tensorflow using conda
Another way to create python environments is using conda. You can download and install the conda by following this instruction. After installing conda, you can create a new environment by the command:
conda create -n myenv python
Then, you can activate your environment:
conda activate myenv
Finally, you can install ‘tensorflow’ using pip or conda if you want.
conda install -c conda-forge tensorflow
Summary
In this tutorial, I’ve showed you how to solve the error “ModuleNotFoundError: No module named ‘tensorflow’” In Python. You can install ‘tensorflow’ directly with pip, but it is recommended to create an environment by the Python virtualenv or conda.
Maybe you are interested in similar errors:
- No module named ‘pkg_resources’ in Python
- How To ModuleNotFoundError: No Module Named ‘absl’ In Python

Hello, I’m Joseph Stanley. My major is IT and I want to share programming languages to you. If you have difficulty with JavaScript, TypeScript, C#, Python, C, C++, Java, let’s follow my articles. They are helpful for you.
Job: Developer
Name of the university: HUST
Major: IT
Programming Languages: JavaScript, TypeScript, C#, Python, C, C++, Java