Tensorflow protobuf incompatibility - tensorflow

I could not get the tensorflow Variables to work because of protobuf incompatibility. Appreciate if someone can suggest how to fix it.
The following is the error:
$ python a.py
Traceback (most recent call last):
File "a.py", line 20, in <module>
a = tf.Variable(tf.zeros(2))
File "/opt/miniconda3/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/opt/miniconda3/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 177, in _variable_handle_from_shape_and_dtype
handle_data.shape_and_type.append(
AttributeError: 'google.protobuf.pyext._message.RepeatedCompositeCo' object has no attribute 'append'
(base) kanduru#SJC-L-00060215:/mnt/c/Users/kanduru/Documents/Courses/MIT/skunk/Auto-Surprise$
and the code is
import tensorflow as tf
a = tf.Variable(tf.zeros(2))
$ pip list | grep tensorflow
tensorflow 2.7.0
tensorflow-estimator 2.7.0
$ pip list | grep protobuf
protobuf 4.21.1

There could be an issue with the TensorFlow installation or TensorFlow version compatibility with existing libraries. protobuf gets installed itself with its specific version compatible to Tensorflow version while installing TensorFlow.
Could you please try again by upgrading the TensorFlow version to the latest version using the code below:
pip install --upgrade pip
pip install --upgrade tensorflow #or
pip install tensorflow==2.10
Please have a look at this Tensorflow install guide for more details.
Let us know if the issue still persists. Thank you.

Related

ModuleNotFoundError: No module named 'absl'

I followed instructions (https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html) to install the Tensorflow Object Detection API. I use Anaconda on ubuntu18.4 and all of the steps in the instructions seemed to complete OK.
When I train to train my model with the following command:
python model_main_tf2.py --model_dir=models/my_ssd_resnet50_v1_fpn --pipeline_config_path=models/my_ssd_resnet50_v1_fpn/pipeline.config
I get the following error:
Traceback (most recent call last):
File "model_main_tf2.py", line 31, in <module>
from absl import flags
ModuleNotFoundError: No module named 'absl'
I get the error mentioned in the headline. I would be very thankful if someone could help me with a code example to solve the problem.
You need the absl package; to install it, use either one of the following:
pip install absl-py
or if you are in a Conda environment:
conda install -c anaconda absl-py

tf/tflearn incompatibility, 'tensorflow.contrib' module not found

I use:
tensorflow 2.0.0-beta1
tflearn 0.3.2
I get: ModuleNotFoundError: No module named 'tensorflow.contrib'
Which recent version of tf/tflearn are compatible?
I reinstalled tensorflow and it somehow worked
pip install --upgrade --force-reinstall tensorflow

Issue while installing Tensorflow

While installing tensorflow(CPU only) I am facing below error :
>>> import tensorflow as tf
Traceback (most recent call last): File "", line 1, in
ImportError: No module named 'tensorflow'
I have python version 3.5
Did you first try:
pip3 install --upgrade tensorflow
It's maybe due to some missing .py files. Download the package from Github link and paste it on python35/Lib/site-packages
import tensorflow as tf
invokes tensorflow not install it there is great article how to install on tensorflow website.
You have not mentioned platform/OS you working on also steps taken if any before trying this command.
best thing for beginners I feel is Anaconda which is suit of packages required for data science.
Give it a try.
python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
You can search for the appropriate version you wish to install and update in the above mentioned url.
Try to install an old version of Tensorflow as:
pip install tensorflow==1.5.0
After installing the old version retry with the newest version, for example:
pip install tensorflow==1.9.0

NameError: name 'core' is not defined

I'm following the turtorial https://www.tensorflow.org/install/install_windows, But when I try to import tensorflow, it comes with an error:
Traceback (most recent call last):
File "", line 1, in
import tensorflow as tf
File "D:\Python 3.5.3\lib\site-packages\tensorflow__init__.py", line 51, in
del core
NameError: name 'core' is not defined
The tensorflow installation command is
pip3 install --upgrade tensorflow
The full code is here
>
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
The python version is 3.5.3 by the way
Is there any way to solve this problem? Thanks in advance.
I have solved this problem by unticking the option 'Precompile standard library' while installing Python.
pip uninstall tensorflow
pip install tensorflow
solved the issue for me

TensorFlow pip installation issue: cannot import name 'descriptor'

I'm seeing the following error when installing TensorFlow:
ImportError: Traceback (most recent call last):
File ".../graph_pb2.py", line 6, in
from google.protobuf import descriptor as _descriptor
ImportError: cannot import name 'descriptor'
This error signals a mismatch between protobuf and TensorFlow versions.
Take the following steps to fix this error:
Uninstall TensorFlow.
Uninstall protobuf (if protobuf is installed).
Reinstall TensorFlow, which will also install the correct protobuf dependency.
I faced the similar issue, after trial and error, I used the below logic to run the program:
pip install --upgrade --no-deps --force-reinstall tensorflow
This will make sure to uninstall and reinstall the program from fresh. It works!
I would be extra careful before uninstalling/reinstalling other packages such as protobuf. What I think would most likely be the issue is difference in versions. As of writing this, the most recent release of python is 3.7 while tensorflow is only compatible up to 3.6.
If you're using a 3rd party distribution like Anaconda, this can get hidden from you. In this case I would recommend creating a new environment in Anaconda, with python 3.6 and then installing tensorflow: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python
Try this:
pip uninstall protobuf
brew install protobuf
mkdir -p
/Users/alexeibendebury/Library/Python/2.7/lib/python/site-packages
echo 'import site;
site.addsitedir("/usr/local/lib/python2.7/site-packages")' >>
/Users/alexeibendebury/Library/Python/2.7/lib/python/site-packages/homebrew.pth