ModuleNotFoundError: No module named 'absl' - tensorflow

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

Related

Tensorflow protobuf incompatibility

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.

rqt_graph pyqt binding of qt_gui_cpp library

I am using ROS-melodic in ubuntu 18.04 LTS. I am getting this error:
Could not import "pyqt" bindings of qt_gui_cpp library - so C++ plugins will not be available:
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_gui_cpp/cpp_binding_helper.py", line 43, in <module>
from . import libqt_gui_cpp_sip
ImportError: dynamic module does not define module export function (PyInit_libqt_gui_cpp_sip)
however I have installed pyqt5 and pydot manually, rqt_graph shows up but with this warning. I want to know what can I do to get it right? Is this going to be problem in future? Now rqt_graph is loading but I don't know if this will mess up/create lacking in the graph?
Try uninstalling double packages if any using
pip3 uninstall PyQt5-sip PyQt5
Then try importing it in python3 to check if any other version is there.
If the import is successful then try running the command again
rosrun rqt_graph rqt_graph
if still some error exists install
pip3 install PyQt5==5.12

Tensorflow CPU Version Installation Error

I am running Ubuntu by using Virtualbox on Windows10.
I installed Tensorflow CPU version in terminal using pip3 install --upgrade tensorflow as per instruction given in official site of Tensorflow. And when I tried to validate installation as import tenorflow as tf it showed following error:
Traceback (most recent call last):
File "<stdin>", line1, in <module>
ImportError: No module named tensorflow
What should I do, to fix this error?

skflow with Docker images gets learn.datasets not imported error

I set the docker image with Dockerfile below.
FROM gcr.io/tensorflow/tensorflow:latest-devel
RUN pip install --upgrade pip
RUN pip install scikit-learn
RUN pip install scipy
RUN pip install pandas
I am using Pycharm and set the remote Docker tf library.
The below file runs with an error which says ' AttributeError: 'module' object has no attribute 'datasets' '
https://github.com/tensorflow/tensorflow/blob/cc9bfbf8ef4a3dea6514ad939d238f7442188247/tensorflow/examples/skflow/text_classification_cnn.py
Do I have to compile some source codes before running the test code, or can I not run the code in Windows? Below is the error messages.
f58474f68f97:python -u /opt/project/examples/skflow/text_classification_cnn.py
Traceback (most recent call last):
File "/opt/project/examples/skflow/text_classification_cnn.py", line 30, in <module>
dbpedia = learn.datasets.load_dataset('dbpedia')
AttributeError: 'module' object has no attribute 'datasets'
Please update your TensorFlow to latest version. That docker image is probably outdated.

ImportError: No module named core.framework.graph_pb2

When I follow the Installation for linux from tensorflow offical site, everything is fine until the last step: Train your first TensorFlow neural net model.
When I execute the command, python tensorflow/models/image/mnist/convolutional.py, An ImportError promps.
Traceback (most recent call last):
File "tensorflow/models/image/mnist/convolutional.py", line 13, in <module>
import tensorflow.python.platform
File "/home/guo/haplox/Github/tensorflow/tensorflow/__init__.py", line 4, in <module>
from tensorflow.python import *
File "/home/guo/haplox/Github/tensorflow/tensorflow/python/__init__.py", line 13, in <module>
from tensorflow.core.framework.graph_pb2 import *
ImportError: No module named core.framework.graph_pb2
My OS is 14.04.1-Ubuntu.
I have met the exactly same issue. once your have installed the tensorflow successfully, it's not about the library dependency anymore.
if your executed the convolution.py 100% accurately as manual and get the exception like below
ImportError: No module named core.framework.graph_b2
this means you are executing the python script exactly under the cloned project root directory,let's say the root named "src".
src$python tensorflow/models/image/mnist/convolutional.py
please try to execute the script in the parent directory of the cloned root directory. for example, if your just clone the tensorflow under src dir, goto its parent dir like xxx and do it again.
xxx$python src/tensorflow/models/image/mnist/convolutional.py
bingo, it works like a charm!
I had the same issue and the solution was to uninstalled protocol buffer v2.6.
TensorFlow requires protocol buffer v3.0, which should come with your TensorFlow installation/source. Hope this helps.
Most probably you have either outdated version of:
python's six module. Install the newest one (pip install six) or upgrade your old one (pip install --upgrade six)
protobuf
I solved it by using virtualenv, but there are many other factors which may cause the same error.
More solutions are at Github issues #81, #61,
#51.
For me, the solution was to run with python3 instead python