My python version is python3.8.8.
I installed tensorflow2.7 on a linux server.
And when I import tensorflow.keras. It shows error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 41, in <module>
from tensorflow.python.eager import context
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/eager/context.py", line 47, in <module>
from tensorflow.python.util.deprecation import deprecated
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/util/deprecation.py", line 32, in <module>
from tensorflow.tools.docs import doc_controls
ModuleNotFoundError: No module named 'tensorflow.tools'
I tried to uninstall tensorflow2.7 and install older version tensorflow2.2
the error becomes:
Traceback (most recent call last):
File "cnn_mnist1.py", line 7, in <module>
import tensorflow.keras as keras
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/research/dept8/msc/xcxia21/anaconda3/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 53, in <module>
from tensorflow.core.framework.graph_pb2 import *
ModuleNotFoundError: No module named 'tensorflow.core'
I am confused about why I need to import tensorflow.tools or tensorflow.core when I only want to import tensorflow.keras?
Someone told me I should build a virtual environment to deal with it. But I would like to know why tensorflow.tools and tensorflow.core are missing?
Besides, when I install tensorflow using pip. The installation always stops(see below). Several minutes later I have to terminate it. Does it cause some packages missing?
Thank you!
Tensorflow 2.7 requires to install keras individually with pip install keras an then you can use keras like before the release: from tensorflow import keras.
Related
I've read multiple posts regarding this problem however no luck fixing it.
I am using tensorflow-cpu version 2.3.1, Python 3.7.3. I have downloaded using pip. I keep on getting ImportError and not sure what to do from here, most post talks about tensorflow-gpu version.
Here is my full Traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\haneu\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
After uninstalling all Visual Studio previous version and re-installing new one, it got rid of ImportError thanks to Tensorflow Error: ImportError: DLL load failed: The specified module could not be found
However after that I kept on getting ModuleNotFoundError everytime I've got this, uninstalled that module and re-installed it. My guess is that there were versions not compatible with each other. But anyways it had fixed my problem.
I've looked through previous answers to similar questions but couldn't find the answer that worked for me.
I've worked with TensorFlow for a long time. Currently trying out Yolov4 which has a requirement to use Tensorflow version 2.3.0, so I decided to install that one.
Anaconda's latest release is 2.1.0 that works great on my computer. So since that was not enough, I created a new environment and installed Tensorflow with pip install tensorflow-gpu which installs version 2.3.0 seemingly without errors.
Then for the import tensorflow as tf I get this error. Any ideas what to try to resolve this?
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
Looks like the problem was the old version of Redistributable for Visual Studio.
With the new version from here, it seems to work thus far!
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
I had a similar problem and update Visual Studio (https://visualstudio.microsoft.com/pt-br/downloads/) worked for me.
Here's the full error:
Traceback (most recent call last):
File "C:\Users\richa\Documents\_Projects_\Astr0loger\interface.py", line 26, in <module>
from controller import choose_best_stocks
File "C:\Users\richa\Documents\_Projects_\Astr0loger\controller.py", line 10, in <module>
from trainer import get_data, train_model, test_model
File "C:\Users\richa\Documents\_Projects_\Astr0loger\trainer.py", line 12, in <module>
import tensorflow as tf
File "C:/Users/richa/Documents/_Projects_/Astr0loger/astrology_env/Lib/site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:/Users/richa/Documents/_Projects_/Astr0loger/astrology_env/Lib/site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:/Users/richa/Documents/_Projects_/Astr0loger/astrology_env/Lib/site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:/Users/richa/Documents/_Projects_/Astr0loger/astrology_env/Lib/site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:/Users/richa/Documents/_Projects_/Astr0loger/astrology_env/Lib/site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:/Users/richa/Documents/_Projects_/Astr0loger/astrology_env/Lib/site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Apparently there are three common causes/fixes to the problem:
Python is 32 bit while the system is 64 bit, or vice versa. I checked, that is not the case.
cpu doesn't support AVX2 instructions - I tried tensorflow-gpu, same issue, so I don't think that's it
You need to install the MSVC 2019 redistributable - I checked, I have it
AAAAAAAAAAH What do I do?
Well, turns out the error was fixed by installing an older version of Tensorflow; 2.0.0. If you're having the same issue, try several versions of tensorflow.
i have installed tensorflow in virtualenv as well as regular system install and added all the required directories to Path
i am using python 3.6.0
installed tensorflow cpu only
import tensorflow as tf
Throws:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\env\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-
import
File "C:\env\lib\site-packages\tensorflow\python\__init__.py", line 59, in
<module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\env\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line
6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\env\lib\site-packages\google\protobuf\descriptor.py", line 47, in
<module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
Please upgrade your Python Version from 3.6.0 to 3.6.1 and your issue will be resolved.
For more information, please refer Github Issue 1 and Github Issue 2
I installed tensorflow using anaconda distribution and I am unable to use the same in python.
When I import tensorflow using import tensorflow I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kaxilnaik/anaconda/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/Users/kaxilnaik/anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/Users/kaxilnaik/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/Users/kaxilnaik/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/Users/kaxilnaik/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "/Users/kaxilnaik/anaconda/lib/python2.7/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"z\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x12\x14\n\x0cunknown_rank\x18\x03 \x01(\x08\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tB2\n\x18org.tensorflow.frameworkB\x11TensorShapeProtosP\x01\xf8\x01\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
I tried reinstalling anaconda as well as uninstalling protobuf which I found as an answer somewhere in stackoverflow.
You should uninstall tensorflow as well, and make sure protobuf is uninstalled. You can try brew uninstall protobuf as well. Then reinstall protobuf, and tensorflow. Tensorflow requires protobuf version 3.x
pip install 'protobuf>=3.0.0a3'
You can test your protobuf version:
import google.protobuf
>>> print google.protobuf.__version__