Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'keras' and 'tensorflow' #9

Open
Zikca opened this issue Jul 16, 2024 · 4 comments
Open

ModuleNotFoundError: No module named 'keras' and 'tensorflow' #9

Zikca opened this issue Jul 16, 2024 · 4 comments

Comments

@Zikca
Copy link

Zikca commented Jul 16, 2024

I can install tfkan correctly with jupyter notebook, but I can't import it
![image](https://github.com/user-attachments/assets/2df1656c-e558-4375-b4bc-497117c6ebf8
image
image

@ZPZhou-lab
Copy link
Owner

First, we may check the Python executor jupyter use by:

import sys
print(sys.executable)

make sure that jupyter use the environment where packages installed.

If this is done then restart the kernel and maybe you could try:

import tensorflow as tf
from tensorflow import keras
print(tf.__version__)

@Zikca
Copy link
Author

Zikca commented Jul 16, 2024

Thanks for your reply. the conda environment named tfkan, The results are shown below
image

@ZPZhou-lab
Copy link
Owner

ZPZhou-lab commented Jul 16, 2024

from the information you provided, the packages(tensorflow, keras, tfkan, ...) have been installed in conda envs tfkan(the path /public/home/mdl/anaconda3/envs/tfkan/lib/python3.8)

However, from sys.executable info in jupyter notebook cell, the jupyter is using default python env /public/home/mdl/anaconda3/bin/python, this is why you install the packages while you can not import them.

To fix this, you now have installed the kernelspec tfkan by:

ipython kernel install --user --name=tfkan

next, remember to change the jupyter notebook kernel you use from right upper corner:

image

or click the menu from top Kernel -> Change kernel...

If you can not find your tfkan kernel, maybe you need to restart your jupyter service first!

Hope this can help you, best🤗

@Zikca
Copy link
Author

Zikca commented Jul 17, 2024

Thanks for your assistance! Good luck to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants