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
import tensorflow.compat.v2 could not be resolved #67331
Comments
@Yummyto, pip install --upgrade protobuf - Use protobuf version 3.19.4 for when using object detection
- Download builder.py from [github repo](https://github.com/protocolbuffers/protobuf/blob/main/python/google/protobuf/internal/builder.py)
- Place this downloaded builder.py inside your protobuf installation Thank you! |
I got this error when I tried to install protobuf 3.19.4 ERROR: Exception: During handling of the above exception, another exception occurred: Traceback (most recent call last): Thank you! |
I now installed the protobuf 3.19.4 and added to this path (C:\Users\Liam\Anaconda3\lib\site packages\google\protobuf\internal_init_.py) however I still got the same error ImportError: cannot import name 'builder' from 'google.protobuf.internal' (C:\Users\Liam\Anaconda3\lib\site-packages\google\protobuf\internal_init_.py). Should I copy the code of builder.py then and paste it to init.py? |
I now got it and resolved the problem. However it still got me this new error AttributeError: module 'tensorflow.compat.v2' has no attribute 'internal'. What should I do? Thank you! |
This is the error that I got AttributeError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\object_detection\builders\model_builder.py in ~\Anaconda3\lib\site-packages\object_detection\meta_architectures\deepmac_meta_arch.py in ~\Anaconda3\lib\site-packages\object_detection\models\keras_models\resnet_v1.py in ~\AppData\Roaming\Python\Python37\site-packages\keras_init_.py in ~\AppData\Roaming\Python\Python37\site-packages\keras\distribute_init_.py in ~\AppData\Roaming\Python\Python37\site-packages\keras\distribute\sidecar_evaluator.py in ~\AppData\Roaming\Python\Python37\site-packages\keras\optimizers_init_.py in ~\AppData\Roaming\Python\Python37\site-packages\keras\backend.py in ~\AppData\Roaming\Python\Python37\site-packages\keras\backend_config.py in AttributeError: module 'tensorflow.compat.v2' has no attribute 'internal' |
@Yummyto, |
Thank you so much for your help. I do have a question, what is the should I do since I get this error prompt AttributeError: module 'tensorflow.keras.optimizers' has no attribute 'experimental'? |
@Yummyto, https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/SGD Thank you! |
Issue type
Build/Install
Have you reproduced the bug with TensorFlow Nightly?
Yes
Source
source
TensorFlow version
2.10.1
Custom code
Yes
OS platform and distribution
Windows
Mobile device
No response
Python version
3.7.3
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
Traceback (most recent call last):
File "Tensorflow/models/research/object_detection/model_main_tf2.py", line 31, in
from object_detection import model_lib_v2
File "C:\Users\Liam\Anaconda3\lib\site-packages\object_detection\model_lib_v2.py", line 29, in
from object_detection import eval_util
File "C:\Users\Liam\Anaconda3\lib\site-packages\object_detection\eval_util.py", line 35, in
from object_detection.metrics import coco_evaluation
File "C:\Users\Liam\Anaconda3\lib\site-packages\object_detection\metrics\coco_evaluation.py", line 28, in
from object_detection.utils import object_detection_evaluation
File "C:\Users\Liam\Anaconda3\lib\site-packages\object_detection\utils\object_detection_evaluation.py", line 46, in
from object_detection.utils import label_map_util
File "C:\Users\Liam\Anaconda3\lib\site-packages\object_detection\utils\label_map_util.py", line 29, in
from object_detection.protos import string_int_label_map_pb2
File "C:\Users\Liam\Anaconda3\lib\site-packages\object_detection\protos\string_int_label_map_pb2.py", line 9, in
from google.protobuf.internal import builder as builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (C:\Users\Liam\Anaconda3\lib\site-packages\google\protobuf\internal_init.py)
Standalone code to reproduce the issue
Relevant log output
No response
The text was updated successfully, but these errors were encountered: