. Advertisement .
..3..
. Advertisement .
..4..
I get the “importerror: cannot import name ‘abs’” issue when trying to generate tfrecord using generate_tfrecord.py. Here is the detail of the error I got the error message:
(tensorflow) C:\Users\ice305\tensorflow\models\research\object_detection>python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record
Traceback (most recent call last):
File "generate_tfrecord.py", line 17, in <module>
import tensorflow as tf
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 81, in <module>
from tensorflow.python import keras
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\__init__.py", line 24, in <module>
from tensorflow.python.keras import activations
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\activations\__init__.py", line 22, in <module>
from tensorflow.python.keras._impl.keras.activations import elu
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\_impl\keras\__init__.py", line 21, in <module>
from tensorflow.python.keras._impl.keras import activations
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\_impl\keras\activations.py", line 23, in <module>
from tensorflow.python.keras._impl.keras import backend as K
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\_impl\keras\backend.py", line 38, in <module>
from tensorflow.python.layers import base as tf_base_layers
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\layers\base.py", line 25, in <module>
from tensorflow.python.keras.engine import base_layer
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\engine\__init__.py", line 21, in <module>
from tensorflow.python.keras.engine.base_layer import InputSpec
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 33, in <module>
from tensorflow.python.keras import backend
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\keras\backend\__init__.py", line 22, in <module>
from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'
(tensorflow) C:\Users\ice305\tensorflow\models\research\object_detection>
Please give me some advice to solve this problem.
The cause: I think the cause of this error is there is a previous installation of tensorflow available.
The solution: These below steps will help you fix this error:
And also need to delete all tensorflow related folders from
You can create a virtual environment and install the TF-GPU. It’s safer and faster.
OS : Ubuntu 18.04.1
Python Version 3.6
Solution:
Tensorflow 1.10 uninstalled
python3 -m pip uninstall tensorflow
It was reinstalled again
python3 -m pip install tensorflow==1.8.0
This problem is caused by older versions of tensorflow dependencies such as protobuff, which are installed during tensorflow install. To use tensorflow 1,10 you will need to either uninstall the rest of these dependencies or upgrade them.
These packages must be removed if you wish to install 1.10.1
Then,
sudo python3 -m pip uninstall tensorflow
. If a tensorflow has been installed by root user, then it should be installed usingpython3 -m pip install tensorflow --user --no-cache
If you have this problem still persist, then follow the above steps and
find ~/ -name tensorflow
. Delete any folders that appear and retry installation.