keras icon indicating copy to clipboard operation
keras copied to clipboard

Module not found errors 3.4.1

Open O-Memis opened this issue 1 year ago • 10 comments
trafficstars

Not useful. After I updated my libraries in Anaconda, all of my Keras codes started to give dramatic errors. I can import the Keras, but can not use it! I re-installed but the situation is same. I don't know how the dependencies or methods changed, but you should consider how people are using these. Now I have to install a previous version, but which one?

ModuleNotFoundError: No module named 'keras.layers' ModuleNotFoundError: No module named 'keras.optimizers' ModuleNotFoundError: No module named 'keras.regularizers' ModuleNotFoundError: No module named 'tensorflow.keras'

O-Memis avatar Aug 09 '24 11:08 O-Memis

I checked and renewed all the libraries, I used pip cache purge, then I installed 2.15.0 for both tensorflow and keras. But different kinds of errors are still occurring. Other versions also did not helped.

Code: import keras Error: ModuleNotFoundError: No module named 'tensorflow.compat'

Code: print(tf.version) Error: AttributeError: module 'tensorflow' has no attribute 'version'

O-Memis avatar Aug 09 '24 12:08 O-Memis

Can you please install latest Keras version and you can use TensorFlow as a backend. https://anaconda.org/conda-forge/keras

sachinprasadhs avatar Aug 09 '24 18:08 sachinprasadhs

I have already installed the latest versions of them. It was already 3.4.1 , what is the difference of "conda install conda-forge::keras" ?? I showed the errors in my first message. Now I am using TensorFlow & keras 2.10 without any problems, for now.

O-Memis avatar Aug 10 '24 20:08 O-Memis

Could you please try by creating a fresh environment and install the Keras/TensorFlow latest package and import the package as below

import keras
from keras import layers, optimizers, regularizers 

sachinprasadhs avatar Aug 14 '24 03:08 sachinprasadhs

image

WilliamQue avatar Aug 17 '24 16:08 WilliamQue

you can do keras.src.layers in that case

sachinprasadhs avatar Aug 20 '24 19:08 sachinprasadhs

you can do keras.src.layers in that case

I really can do by this, but import parts of many codes must be modified. are you serious?

WilliamQue avatar Aug 23 '24 09:08 WilliamQue

I don't see any issues when I try from my side, here is the working Gist https://colab.sandbox.google.com/gist/sachinprasadhs/257ce4b5995bbba7ad526cb7c045734b/20103.ipynb.

Note: We only release PyPi Keras package as our official release, all other releases are not maintained or released by us.

sachinprasadhs avatar Aug 23 '24 18:08 sachinprasadhs

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Sep 07 '24 01:09 github-actions[bot]

I haven't tried the suggestion in a fresh environment yet, As I said before, I reinstalled TensorFlow & keras 2.10 without any problems, for now. I can share the list of all the libraries with versions, if you want.

O-Memis avatar Sep 07 '24 19:09 O-Memis

Hi @O-Memis,

Are you still able to reproduce the issue ? If yes, could you please try upgrading to the latest version of Keras(3.7.0). Thanks!

sonali-kumari1 avatar Dec 18 '24 09:12 sonali-kumari1

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Jan 02 '25 02:01 github-actions[bot]

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

github-actions[bot] avatar Jan 17 '25 01:01 github-actions[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Jan 17 '25 01:01 google-ml-butler[bot]

I also have a fresh Spyder install and have the same issue after installing latest Keras version: conda install conda-forge::keras

Image

It seams the error is in the optree library. I can also reproduce all the steps as @WilliamQue (https://github.com/keras-team/keras/issues/20103#issuecomment-2294912797)

alemangioni avatar Apr 10 '25 20:04 alemangioni