[GH-ISSUE #78] Error No module named 'keras.engine' when starting the server with classify #52

Closed
opened 2026-10-15 18:03:47 +00:00 by bsakaguchi · 6 comments
Owner

Originally created by @nightboysfm on GitHub (Jul 9, 2023).
Original GitHub issue: https://github.com/SillyTavern/SillyTavern-Extras/issues/78

I started the server with classify module and it gave me the error "No module named 'keras.engine'" when the server is trying to load the bert model.

To cut it short after some investigation the issue is that I had keras 2.13.1 and tensorflow 2.13.0, seem not compatible but I didn't research much on this point.

I saw this with :
G:\AI\SillyTavern-extras>pip install keras
Requirement already satisfied: keras in .......\python310\site-packages (2.13.1)

G:\AI\SillyTavern-extras>pip install tensorflow
Requirement already satisfied: tensorflow in .......\python310\site-packages (2.13.0)

I searched for a keras 2.13.0 package but it doesn't seem to exist, seem the cause of the issue ? So search for a version that exist for both package.

To fix the issue I did :
pip uninstall keras
pip uninstall tensorflow
pip install tensorflow==2.12.0
pip install keras==2.12.0

You can close this, but if anyone else have this issue you have some information.
Maybe also you can specify working version in requirements.txt ? Not sure what is possible to do on your side.

Originally created by @nightboysfm on GitHub (Jul 9, 2023). Original GitHub issue: https://github.com/SillyTavern/SillyTavern-Extras/issues/78 I started the server with classify module and it gave me the error "No module named 'keras.engine'" when the server is trying to load the bert model. To cut it short after some investigation the issue is that I had keras 2.13.1 and tensorflow 2.13.0, seem not compatible but I didn't research much on this point. I saw this with : G:\AI\SillyTavern-extras>pip install keras Requirement already satisfied: keras in .......\python310\site-packages (2.13.1) G:\AI\SillyTavern-extras>pip install tensorflow Requirement already satisfied: tensorflow in .......\python310\site-packages (2.13.0) I searched for a keras 2.13.0 package but it doesn't seem to exist, seem the cause of the issue ? So search for a version that exist for both package. To fix the issue I did : pip uninstall keras pip uninstall tensorflow pip install tensorflow==2.12.0 pip install keras==2.12.0 You can close this, but if anyone else have this issue you have some information. Maybe also you can specify working version in requirements.txt ? Not sure what is possible to do on your side.
Author
Owner

@Cohee1207 commented on GitHub (Jul 9, 2023):

Did you install without conda into the system python environment?

<!-- gh-comment-id:1627780431 --> @Cohee1207 commented on GitHub (Jul 9, 2023): Did you install without conda into the system python environment?
Author
Owner

@MoeMonsuta commented on GitHub (Jul 13, 2023):

I think I produced this exact problem when I installed Dreambooth requirements and it installed Tensorflow when I already had Tensorflow-Intel installed. Doing pip uninstall tensorflow solved the "No module named 'keras.engine'" issue for me. I have an Intel CPU so I kept the Tensorflow-Intel library installed.

pip list (List installed packages.) and pip check (Verify installed packages have compatible dependencies) helped me look into version discrepancies.

<!-- gh-comment-id:1633409433 --> @MoeMonsuta commented on GitHub (Jul 13, 2023): I think I produced this exact problem when I installed Dreambooth requirements and it installed Tensorflow when I already had Tensorflow-Intel installed. Doing `pip uninstall tensorflow` solved the **"No module named 'keras.engine'"** issue for me. I have an Intel CPU so I kept the [Tensorflow-Intel](https://pypi.org/project/tensorflow-intel/) library installed. `pip list` (List installed packages.) and `pip check` (Verify installed packages have compatible dependencies) helped me look into version discrepancies.
Author
Owner

@Cohee1207 commented on GitHub (Jul 13, 2023):

Install into a conda environment or venv please. System install is not something easy to support because it creates incompatibility.

<!-- gh-comment-id:1634991594 --> @Cohee1207 commented on GitHub (Jul 13, 2023): Install into a conda environment or venv please. System install is not something easy to support because it creates incompatibility.
Author
Owner

@nightboysfm commented on GitHub (Jul 18, 2023):

Sorry for the late reply, I did vanilla install, something like this:
git clone https://github.com/SillyTavern/SillyTavern-extras
cd SillyTavern-extras
python -m pip install -r requirements-complete.txt

I did nothing like installing in a specific environment, I'm a noob when it come to python so I just followed instructions, I think it's system wide.
Not sure it's worth to mention but I installed stable diffusion webui a few weeks ago, maybe the conflict come from there. I think it use also conda and I did want to prevent conflits, reason of the vanilla install.

Maybe more specific instructions about installing ST-extras into a venv could prevent this issue.
Or maybe I should have just installed with conda, I don't know if it handles well parallel installations with stable diffusion.

<!-- gh-comment-id:1640514250 --> @nightboysfm commented on GitHub (Jul 18, 2023): Sorry for the late reply, I did vanilla install, something like this: git clone https://github.com/SillyTavern/SillyTavern-extras cd SillyTavern-extras python -m pip install -r requirements-complete.txt I did nothing like installing in a specific environment, I'm a noob when it come to python so I just followed instructions, I think it's system wide. Not sure it's worth to mention but I installed stable diffusion webui a few weeks ago, maybe the conflict come from there. I think it use also conda and I did want to prevent conflits, reason of the vanilla install. Maybe more specific instructions about installing ST-extras into a venv could prevent this issue. Or maybe I should have just installed with conda, I don't know if it handles well parallel installations with stable diffusion.
Author
Owner

@Cohee1207 commented on GitHub (Jul 18, 2023):

The documentation in readme explicitly says that conda is recommended and provides line by line instructions
The purpose of it is to handle parallel installation so there should not be any issues

<!-- gh-comment-id:1640636757 --> @Cohee1207 commented on GitHub (Jul 18, 2023): The documentation in readme explicitly says that conda is recommended and provides line by line instructions The purpose of it is to handle parallel installation so there should not be any issues
Author
Owner

@nightboysfm commented on GitHub (Jul 27, 2023):

I mean it would be an improvement to modify the vanilla instructions to use a venv, it doesn't seem complicated, but I don't know if it have other sides effects.
We all know that in IT "should not" mean "will happen at some point", so that was just and idea to prevent issues when using vanilla install.
For me the issue is solved, so I close this. Thanks for the explanations.

<!-- gh-comment-id:1653535057 --> @nightboysfm commented on GitHub (Jul 27, 2023): I mean it would be an improvement to modify the vanilla instructions to use a venv, it doesn't seem complicated, but I don't know if it have other sides effects. We all know that in IT "should not" mean "will happen at some point", so that was just and idea to prevent issues when using vanilla install. For me the issue is solved, so I close this. Thanks for the explanations.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SillyTavern/SillyTavern-Extras#52
No description provided.