'Unable to run anipose due to ImportError: cannot import name 'keras_export' from 'tensorflow.python.util.tf_export'
I've been attempting to install and run anipose in Ubuntu 18.04 I keep getting the same import error though I've made sure keras is installed. I've also searched for version compatibility because in the anipose environment setup tensorflow version is set to 1.13.1, though I see when I install everything it downloads tensorflow 2.8.0
(anipose) nimrod@msi-ubuntu:~/anipose_projects/hand-demo-unfilled$ anipose run-all
Analyzing videos...
Traceback (most recent call last):
File "/home/nimrod/anaconda3/envs/anipose/bin/anipose", line 8, in <module>
sys.exit(cli())
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/anipose.py", line 365, in run_all
pose_videos_all(config)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/common.py", line 168, in fun
return process_all(config, process_session, **args)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/common.py", line 153, in process_all
output[past_folders] = process_session(config, path, **args)
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/pose_videos.py", line 56, in process_session
import deeplabcut
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/deeplabcut/__init__.py", line 14, in <module>
import tensorflow as tf
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/__init__.py", line 30, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 82, in <module>
from tensorflow.python import keras
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/keras/__init__.py", line 24, in <module>
from tensorflow.python.keras import activations
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/keras/activations.py", line 24, in <module>
from tensorflow.python.keras.utils.generic_utils import deserialize_keras_object
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/keras/utils/__init__.py", line 38, in <module>
from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/keras/utils/multi_gpu_utils.py", line 22, in <module>
from tensorflow.python.keras.engine.training import Model
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/keras/engine/__init__.py", line 23, in <module>
from tensorflow.python.keras.engine.base_layer import Layer
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 36, in <module>
from tensorflow.python.keras import initializers
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/keras/initializers/__init__.py", line 20, in <module>
from tensorflow.python.keras.initializers import initializers_v1
File "/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/keras/initializers/initializers_v1.py", line 19, in <module>
from tensorflow.python.util.tf_export import keras_export
ImportError: cannot import name 'keras_export' from 'tensorflow.python.util.tf_export' (/home/nimrod/anaconda3/envs/anipose/lib/python3.7/site-packages/tensorflow/python/util/tf_export.py)
(anipose) nimrod@msi-ubuntu:~/anipose_projects/hand-demo-unfilled$ conda list
# packages in environment at /home/nimrod/anaconda3/envs/anipose:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 4.5 1_gnu
_tflow_select 2.3.0 mkl
absl-py 0.15.0 pyhd3eb1b0_0
anipose 1.0.1 pypi_0 pypi
aniposelib 0.4.3 pypi_0 pypi
apptools 5.1.0 pyhd3eb1b0_0
argon2-cffi 21.3.0 pyhd3eb1b0_0
argon2-cffi-bindings 21.2.0 py37h7f8727e_0
astor 0.8.1 py37h06a4308_0
astunparse 1.6.3 pypi_0 pypi
attrs 21.4.0 pyhd3eb1b0_0
backcall 0.2.0 pyhd3eb1b0_0
beautifulsoup4 4.11.1 py37h06a4308_0
blas 1.0 mkl
bleach 4.1.0 pyhd3eb1b0_0
brotli 1.0.9 pypi_0 pypi
bzip2 1.0.8 h7b6447c_0
c-ares 1.18.1 h7f8727e_0
ca-certificates 2022.3.29 h06a4308_1
cached-property 1.5.2 py_0
cachetools 5.0.0 pypi_0 pypi
certifi 2021.10.8 py37h06a4308_2
cffi 1.15.0 py37hd667e15_1
charset-normalizer 2.0.12 pypi_0 pypi
click 8.1.2 pypi_0 pypi
configobj 5.0.6 py37h06a4308_1
curl 7.82.0 h7f8727e_0
cycler 0.11.0 pypi_0 pypi
dataclasses 0.8 pyh6d0b6a4_7
dbus 1.13.18 hb2f20db_0
debugpy 1.5.1 py37h295c915_0
decorator 5.1.1 pyhd3eb1b0_0
deeplabcut 2.2.1 pypi_0 pypi
defusedxml 0.7.1 pyhd3eb1b0_0
entrypoints 0.4 py37h06a4308_0
envisage 6.0.1 pyhd3eb1b0_0
expat 2.4.4 h295c915_0
ffmpeg 4.2.2 h20bf706_0
filterpy 1.4.5 pypi_0 pypi
flask 2.1.1 pypi_0 pypi
flask-compress 1.12 pypi_0 pypi
flask-ipban 1.1.5 pypi_0 pypi
flatbuffers 2.0 pypi_0 pypi
fontconfig 2.13.1 h6c09931_0
fonttools 4.33.3 pypi_0 pypi
freetype 2.11.0 h70c0345_0
future 0.18.2 py37_1
gast 0.5.3 pyhd3eb1b0_0
glib 2.69.1 h4ff587b_1
gmp 6.2.1 h2531618_2
gnutls 3.6.15 he1e5248_0
google-auth 2.6.6 pypi_0 pypi
google-auth-oauthlib 0.4.6 pypi_0 pypi
google-pasta 0.2.0 pypi_0 pypi
grpcio 1.42.0 py37hce63b2e_0
gst-plugins-base 1.14.0 h8213a91_2
gstreamer 1.14.0 h28cd5cc_2
h5py 2.10.0 py37h7918eee_0
hdf4 4.2.13 h3ca952b_2
hdf5 1.10.4 hb1b8bf9_0
icu 58.2 he6710b0_3
idna 3.3 pypi_0 pypi
imageio 2.18.0 pypi_0 pypi
imgaug 0.4.0 pypi_0 pypi
importlib-metadata 4.11.3 py37h06a4308_0
importlib-resources 5.7.1 pypi_0 pypi
importlib_metadata 4.11.3 hd3eb1b0_0
importlib_resources 5.2.0 pyhd3eb1b0_1
intel-openmp 2021.4.0 h06a4308_3561
ipykernel 6.9.1 py37h06a4308_0
ipython 7.32.0 pypi_0 pypi
ipython_genutils 0.2.0 pyhd3eb1b0_1
ipywidgets 7.6.5 pyhd3eb1b0_1
itsdangerous 2.1.2 pypi_0 pypi
jedi 0.18.1 py37h06a4308_1
jinja2 3.1.1 pypi_0 pypi
joblib 1.1.0 pypi_0 pypi
jpeg 9e h7f8727e_0
jsoncpp 1.9.4 hff7bd54_2
jsonschema 4.4.0 py37h06a4308_0
jupyter 1.0.0 py37_7
jupyter_client 7.2.2 py37h06a4308_0
jupyter_console 6.4.3 pyhd3eb1b0_0
jupyter_core 4.9.2 py37h06a4308_0
jupyterlab_pygments 0.1.2 py_0
jupyterlab_widgets 1.0.0 pyhd3eb1b0_1
keras 2.8.0 pypi_0 pypi
keras-applications 1.0.8 py_1
keras-base 2.3.1 py37_0
keras-preprocessing 1.1.2 pyhd3eb1b0_0
kiwisolver 1.4.2 pypi_0 pypi
krb5 1.19.2 hac12032_0
lame 3.100 h7b6447c_0
ld_impl_linux-64 2.35.1 h7274673_9
libclang 14.0.1 pypi_0 pypi
libcurl 7.82.0 h0b77cf5_0
libedit 3.1.20210910 h7f8727e_0
libev 4.33 h7f8727e_1
libffi 3.3 he6710b0_2
libgcc-ng 9.3.0 h5101ec6_17
libgfortran-ng 7.5.0 ha8ba4b0_17
libgfortran4 7.5.0 ha8ba4b0_17
libgomp 9.3.0 h5101ec6_17
libidn2 2.3.2 h7f8727e_0
libnetcdf 4.6.1 h11d0813_2
libnghttp2 1.46.0 hce63b2e_0
libogg 1.3.5 h27cfd23_1
libopus 1.3.1 h7b6447c_0
libpng 1.6.37 hbc83047_0
libprotobuf 3.19.1 h4ff587b_0
libsodium 1.0.18 h7b6447c_0
libssh2 1.10.0 h8f2d780_0
libstdcxx-ng 9.3.0 hd4cf53a_17
libtasn1 4.16.0 h27cfd23_0
libtheora 1.1.1 h7f8727e_3
libtiff 4.1.0 h2733197_0
libunistring 0.9.10 h27cfd23_0
libuuid 1.0.3 h7f8727e_2
libvorbis 1.3.7 h7b6447c_0
libvpx 1.7.0 h439df22_0
libxcb 1.14 h7b6447c_0
libxml2 2.9.12 h03d6c58_0
llvmlite 0.38.0 pypi_0 pypi
lz4-c 1.8.1.2 h14c3975_0
markdown 3.3.4 py37h06a4308_0
markupsafe 2.1.1 pypi_0 pypi
matplotlib 3.5.1 pypi_0 pypi
matplotlib-inline 0.1.3 pypi_0 pypi
mayavi 4.7.1 py37h94891b3_2
mistune 0.8.4 py37h14c3975_1001
mkl 2021.4.0 h06a4308_640
mkl-service 2.4.0 py37h7f8727e_0
mkl_fft 1.3.1 py37hd3c417c_0
mkl_random 1.2.2 py37h51133e4_0
mock 4.0.3 pyhd3eb1b0_0
msgpack 1.0.3 pypi_0 pypi
msgpack-numpy 0.4.7.1 pypi_0 pypi
nbclient 0.5.13 py37h06a4308_0
nbconvert 6.4.4 py37h06a4308_0
nbformat 5.3.0 py37h06a4308_0
ncurses 6.3 h7f8727e_2
nest-asyncio 1.5.5 py37h06a4308_0
nettle 3.7.3 hbbd107a_1
networkx 2.6.3 pypi_0 pypi
notebook 6.4.8 py37h06a4308_0
numba 0.55.1 pypi_0 pypi
numexpr 2.8.1 pypi_0 pypi
numpy 1.21.5 py37he7a7128_1
numpy-base 1.21.5 py37hf524024_1
oauthlib 3.2.0 pypi_0 pypi
opencv-contrib-python 4.5.5.64 pypi_0 pypi
opencv-python 4.5.5.64 pypi_0 pypi
openh264 2.1.1 h4ff587b_0
openssl 1.1.1n h7f8727e_0
opt-einsum 3.3.0 pypi_0 pypi
packaging 21.3 pyhd3eb1b0_0
pandas 1.3.5 pypi_0 pypi
pandocfilters 1.5.0 pyhd3eb1b0_0
parso 0.8.3 pyhd3eb1b0_0
patsy 0.5.2 pypi_0 pypi
pcre 8.45 h295c915_0
pexpect 4.8.0 pyhd3eb1b0_3
pickleshare 0.7.5 pyhd3eb1b0_1003
pillow 9.1.0 pypi_0 pypi
pip 21.2.2 py37h06a4308_0
pip-autoremove 0.10.0 pypi_0 pypi
prometheus_client 0.13.1 pyhd3eb1b0_0
prompt-toolkit 3.0.29 pypi_0 pypi
prompt_toolkit 3.0.20 hd3eb1b0_0
protobuf 3.19.1 py37h295c915_0
psutil 5.9.0 pypi_0 pypi
ptyprocess 0.7.0 pyhd3eb1b0_2
pyasn1 0.4.8 pypi_0 pypi
pyasn1-modules 0.2.8 pypi_0 pypi
pycparser 2.21 pyhd3eb1b0_0
pyface 7.3.0 py37h06a4308_1
pygments 2.12.0 pypi_0 pypi
pyparsing 3.0.8 pypi_0 pypi
pyqt 5.9.2 py37h05f1152_2
pyrsistent 0.18.0 py37heee7806_0
python 3.7.13 h12debd9_0
python-dateutil 2.8.2 pyhd3eb1b0_0
python-fastjsonschema 2.15.1 pyhd3eb1b0_0
pytz 2022.1 pypi_0 pypi
pywavelets 1.3.0 pypi_0 pypi
pyyaml 6.0 pypi_0 pypi
pyzmq 22.3.0 py37h295c915_2
qt 5.9.7 h5867ecd_1
qtconsole 5.3.0 pyhd3eb1b0_0
qtpy 2.0.1 pyhd3eb1b0_0
readline 8.1.2 h7f8727e_1
requests 2.27.1 pypi_0 pypi
requests-oauthlib 1.3.1 pypi_0 pypi
rsa 4.8 pypi_0 pypi
ruamel-yaml 0.17.21 pypi_0 pypi
ruamel-yaml-clib 0.2.6 pypi_0 pypi
scikit-image 0.18.1 pypi_0 pypi
scikit-learn 1.0.2 pypi_0 pypi
scikit-video 1.1.11 pypi_0 pypi
scipy 1.7.3 py37hc147768_0
send2trash 1.8.0 pyhd3eb1b0_1
setuptools 61.2.0 py37h06a4308_0
shapely 1.8.1.post1 pypi_0 pypi
sip 4.19.8 py37hf484d3e_0
six 1.16.0 pyhd3eb1b0_1
soupsieve 2.3.1 pyhd3eb1b0_0
sqlite 3.38.2 hc218d9a_0
statsmodels 0.13.1 pypi_0 pypi
tables 3.7.0 pypi_0 pypi
tabulate 0.8.9 pypi_0 pypi
tbb 2021.5.0 hd09550d_0
tensorboard 2.8.0 pypi_0 pypi
tensorboard-data-server 0.6.1 pypi_0 pypi
tensorboard-plugin-wit 1.8.1 pypi_0 pypi
tensorflow 2.8.0 pypi_0 pypi
tensorflow-base 1.13.1 mkl_py37h7ce6ba3_0
tensorflow-estimator 1.13.0 py_0
tensorflow-io-gcs-filesystem 0.25.0 pypi_0 pypi
tensorpack 0.11 pypi_0 pypi
termcolor 1.1.0 py37h06a4308_1
terminado 0.13.1 py37h06a4308_0
testpath 0.5.0 pyhd3eb1b0_0
tf-estimator-nightly 2.8.0.dev2021122109 pypi_0 pypi
tf-slim 1.1.0 pypi_0 pypi
threadpoolctl 3.1.0 pypi_0 pypi
tifffile 2021.11.2 pypi_0 pypi
tk 8.6.11 h1ccaba5_0
toml 0.10.2 pypi_0 pypi
tornado 6.1 py37h27cfd23_0
tqdm 4.64.0 pypi_0 pypi
traitlets 5.1.1 pyhd3eb1b0_0
traits 6.2.0 py37h27cfd23_0
traitsui 7.2.1 pyhd3eb1b0_0
typing-extensions 4.1.1 hd3eb1b0_0
typing_extensions 4.1.1 pyh06a4308_0
urllib3 1.26.9 pypi_0 pypi
vtk 8.2.0 py37haa4764d_200
wcwidth 0.2.5 pyhd3eb1b0_0
webencodings 0.5.1 py37_1
werkzeug 2.0.3 pyhd3eb1b0_0
wheel 0.37.1 pyhd3eb1b0_0
widgetsnbextension 3.5.2 py37h06a4308_0
wrapt 1.14.0 pypi_0 pypi
wxpython 4.1.1 pypi_0 pypi
x264 1!157.20191217 h7b6447c_0
xz 5.2.5 h7b6447c_0
yaml 0.2.5 h7b6447c_0
zeromq 4.3.4 h2531618_0
zipp 3.7.0 pyhd3eb1b0_0
zlib 1.2.12 h7f8727e_2
zstd 1.3.7 h0b5b093_0
Tell me if there's any more information I can add
Solution 1:[1]
anipose
supports Tensorflow 1.13.1.
pip install tensorflow==1.13.1
Below import works fine with Tf v2.8.0
from tensorflow.python.util.tf_export import keras_export
Make sure you have installed compatible version between anipose and Tensorflow.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | TFer |