I have installed TF 2.12.0 in a conda environment ‘tf’ and am getting this error in JupyterLab IPYNB Notebook, running in ‘tf’ kernel.
Running this code gives me attribute error
!pip install tensorflow==2.12.0
import tensorflow as tf
print(tf.__version__)
print(tf.version)
Error Log:
Requirement already satisfied: tensorflow==2.12.0 in c:\programdata\anaconda3\lib\site-packages (2.12.0)
Requirement already satisfied: tensorflow-intel==2.12.0 in c:\programdata\anaconda3\lib\site-packages (from tensorflow==2.12.0) (2.12.0)
Requirement already satisfied: keras<2.13,>=2.12.0 in c:\programdata\anaconda3\lib\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (2.12.0)
Requirement already satisfied: absl-py>=1.0.0 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.4.0)
Requirement already satisfied: numpy<1.24,>=1.22 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.22.4)
Requirement already satisfied: tensorflow-estimator<2.13,>=2.12.0 in c:\programdata\anaconda3\lib\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (2.12.0)
Requirement already satisfied: gast<=0.4.0,>=0.2.1 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.4.0)
Requirement already satisfied: typing-extensions>=3.6.6 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (4.5.0)
Requirement already satisfied: h5py>=2.9.0 in c:\programdata\anaconda3\lib\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (3.2.1)
Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.31.0)
Requirement already satisfied: grpcio<2.0,>=1.24.3 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.53.0)
Requirement already satisfied: six>=1.12.0 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.16.0)
Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in c:\programdata\anaconda3\lib\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (3.20.3)
Requirement already satisfied: tensorboard<2.13,>=2.12 in c:\programdata\anaconda3\lib\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (2.12.2)
Requirement already satisfied: packaging in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (23.1)
Requirement already satisfied: astunparse>=1.6.0 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.6.3)
Requirement already satisfied: libclang>=13.0.0 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (16.0.0)
Requirement already satisfied: flatbuffers>=2.0 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (23.3.3)
Requirement already satisfied: google-pasta>=0.1.1 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.2.0)
Requirement already satisfied: termcolor>=1.1.0 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (2.2.0)
Requirement already satisfied: wrapt<1.15,>=1.11.0 in c:\programdata\anaconda3\lib\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.12.1)
Requirement already satisfied: jax>=0.3.15 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.4.8)
Requirement already satisfied: setuptools in c:\programdata\anaconda3\lib\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (58.0.4)
Requirement already satisfied: opt-einsum>=2.3.2 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorflow-intel==2.12.0->tensorflow==2.12.0) (3.3.0)
Requirement already satisfied: wheel<1.0,>=0.23.0 in c:\programdata\anaconda3\lib\site-packages (from astunparse>=1.6.0->tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.37.0)
Requirement already satisfied: scipy>=1.7 in c:\programdata\anaconda3\lib\site-packages (from jax>=0.3.15->tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.7.1)
Requirement already satisfied: ml-dtypes>=0.0.3 in c:\users\esc\appdata\roaming\python\python39\site-packages (from jax>=0.3.15->tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.0.4)
Requirement already satisfied: requests<3,>=2.21.0 in c:\programdata\anaconda3\lib\site-packages (from tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (2.26.0)
Requirement already satisfied: google-auth-oauthlib<1.1,>=0.5 in c:\programdata\anaconda3\lib\site-packages (from tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.0.0)
Requirement already satisfied: werkzeug>=1.0.1 in c:\programdata\anaconda3\lib\site-packages (from tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (2.0.2)
Requirement already satisfied: markdown>=2.6.8 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (3.4.3)
Requirement already satisfied: google-auth<3,>=1.6.3 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (2.17.2)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in c:\users\esc\appdata\roaming\python\python39\site-packages (from tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.8.1)
Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in c:\programdata\anaconda3\lib\site-packages (from tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.7.0)
Requirement already satisfied: rsa<5,>=3.1.4 in c:\programdata\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (4.9)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in c:\programdata\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (5.3.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\programdata\anaconda3\lib\site-packages (from google-auth<3,>=1.6.3->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.2.8)
Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\programdata\anaconda3\lib\site-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.3.1)
Requirement already satisfied: importlib-metadata>=4.4 in c:\users\esc\appdata\roaming\python\python39\site-packages (from markdown>=2.6.8->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (6.5.0)
Requirement already satisfied: zipp>=0.5 in c:\users\esc\appdata\roaming\python\python39\site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (3.15.0)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in c:\programdata\anaconda3\lib\site-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (0.4.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\programdata\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (1.26.7)
Requirement already satisfied: idna<4,>=2.5 in c:\programdata\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (3.2)
Requirement already satisfied: certifi>=2017.4.17 in c:\programdata\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (2021.10.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\programdata\anaconda3\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (2.0.4)
Requirement already satisfied: oauthlib>=3.0.0 in c:\programdata\anaconda3\lib\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard<2.13,>=2.12->tensorflow-intel==2.12.0->tensorflow==2.12.0) (3.2.2)
WARNING: Ignoring invalid distribution -mpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -mpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -mpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -mpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -mpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -mpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\programdata\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\lib\site-packages)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[14], line 3
1 get_ipython().system('pip install tensorflow==2.12.0')
2 import tensorflow as tf
----> 3 print(tf.__version__)
4 print(tf.version)
AttributeError: module 'tensorflow' has no attribute '__version__'
Using version gives same error:
import tensorflow as tf
print(tf.version)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[15], line 2
1 import tensorflow as tf
----> 2 print(tf.version)
AttributeError: module 'tensorflow' has no attribute 'version'
The rest of code also gives same error:
import keras_cv
from tensorflow import keras
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from PIL import Image
# Instantiate the Stable Diffusion model
model = keras_cv.models.StableDiffusion(img_height=512, img_width=512, jit_compile=True)
import keras_cv
from tensorflow import keras
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from PIL import Image
#print(tf.__version__)
# Enable mixed precision
# (only do this if you have a recent NVIDIA GPU)
#keras.mixed_precision.set_global_policy("mixed_float16")
# Instantiate the Stable Diffusion model
model = keras_cv.models.StableDiffusion(img_height=512, img_width=512, jit_compile=True)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[7], line 1
----> 1 import keras_cv
2 from tensorflow import keras
3 import matplotlib.pyplot as plt
File ~\AppData\Roaming\Python\Python39\site-packages\keras_cv\__init__.py:18
1 # Copyright 2022 The KerasCV Authors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
(...)
14
15 # isort:off
16 from keras_cv import version_check
---> 18 version_check.check_tf_version()
19 # isort:on
21 from keras_cv import callbacks
File ~\AppData\Roaming\Python\Python39\site-packages\keras_cv\version_check.py:25, in check_tf_version()
24 def check_tf_version():
---> 25 if parse(tf.__version__) < parse(MIN_VERSION):
26 raise RuntimeError(
27 f"The Tensorflow package version needs to be at least {MIN_VERSION} "
28 "for KerasCV to run. Currently, your TensorFlow version is "
29 f"{tf.__version__}. Please upgrade with `$ pip install --upgrade tensorflow`. "
30 "You can use `pip freeze` to check afterwards that everything is ok."
31 )
AttributeError: module 'tensorflow' has no attribute '__version__'
! conda list
gives these results for tensorflow packages:
tensorboard-data-server 0.7.0 pypi_0 pypi
tensorflow 2.12.0 pypi_0 pypi
tensorflow-estimator 2.12.0 pypi_0 pypi
tensorflow-intel 2.12.0 pypi_0 pypi
View Complete CONDA PACKAGES here
print(tf)
print(tf.__file__)
OUTPUT:
<module 'tensorflow' (namespace)>
None
I cannot figure out why is this error happening? I Already read other solutions but they didn’t work
THIS suggested that there are 2 different kinds of TF: so i have already uninstalled this one : tensorflow-base 2.10.0 and restarted everything, now there is only 1 TF version but same error persists