简体   繁体   English

ModuleNotFoundError:Jupyter Notebook 没有名为“keras”的模块

[英]ModuleNotFoundError: No module named 'keras' for Jupyter Notebook

I was running Jupyter Notebook and the following error occurs我正在运行 Jupyter Notebook,出现以下错误

ModuleNotFoundError模块未找到错误
Traceback (most recent call last) in ---->中的回溯(最近调用最后)---->

from keras.models import Sequential从 keras.models 导入顺序

from keras.layers import (从 keras.layers 导入(
Conv2D, MaxPooling2D, Flatten, Dense, Dropout) Conv2D, MaxPooling2D, Flatten, Dense, Dropout)

ModuleNotFoundError: No module named 'keras' ModuleNotFoundError:没有名为“keras”的模块

I have tried using import sys; sys.path我试过使用import sys; sys.path import sys; sys.path and found this import sys; sys.path并找到了这个

['/home/xxx/notebook',
 '/home/xxx/anaconda3/lib/python37.zip',
 '/home/xxx/anaconda3/lib/python3.7',
 '/home/xxx/anaconda3/lib/python3.7/lib-dynload',
 '',
 '/home/xxx/anaconda3/lib/python3.7/site-packages',
 '/home/xxx/anaconda3/lib/python3.7/site-packages/IPython/extensions',
 '/home/xxx/.ipython']

Is there any problem with the installation?安装有问题吗? Do I need to reinstall everything from python to anaconda. Would some be able to point me to a proper installation of anaconda我需要重新安装从 python 到 anaconda 的所有内容吗?有人可以指点我正确安装 anaconda

BTW, if u have installed python, should you install python package through anaconda again顺便说一句,如果你已经安装了 python,你是否应该再次安装 python package 到 anaconda

Thanks谢谢

You have to install all the dependencies first before using it.在使用它之前,您必须先安装所有依赖项。 Try using尝试使用

  • conda install tensorflow康达安装张量流
  • conda install keras康达安装keras

by installing it with conda command it manage your versions compatibility with other libraries.通过使用 conda 命令安装它,它可以管理您的版本与其他库的兼容性。

with pip install libraries will only install in your current environment and the latest version of the library sometimes latest libraries are not compatible with the other libraries so we have to take care of version compatibility. with pip install libraries 只会安装在您当前的环境中,并且最新版本的库有时与其他库不兼容,因此我们必须注意版本兼容性。

keras is actually part of tensorflow so all you have to do is just keras 实际上是 tensorflow 的一部分,所以你所要做的就是

from tensorflow.keras.models import Sequential

from tensorflow.keras.layers import Dense,Dropout,Activation, Flatten, Conv2D, MaxPooling2D

cheers mate队友的欢呼声

Create a virtual environment and install all packages and specially jupyter-notebook in it.创建一个虚拟环境并在其中安装所有软件包,特别是 jupyter-notebook。 Some times it is necessary to install jupyter-notebook in each virtual environment to work properly with other libraries.有时需要在每个虚拟环境中安装 jupyter-notebook 才能与其他库正常工作。 It is preferred to use anaconda .最好使用anaconda

After creating your virtual env use this command to install jupyter:创建虚拟环境后,使用此命令安装 jupyter:

conda install -c anaconda jupyter

If you have installed all the required packages in a virtual/conda environment, have you tried saving the environment as an ipython kernel?如果您已经在 virtual/conda 环境中安装了所有必需的软件包,您是否尝试将环境保存为 ipython 内核? I got those errors when I tried to launch a jupyter notebook from my virtual environment but I hadn't explicitly created a kernel for it.当我尝试从我的虚拟环境启动 jupyter notebook 时遇到了这些错误,但我没有明确地为它创建内核。

https://ipython.readthedocs.io/en/stable/install/kernel_install.html https://ipython.readthedocs.io/en/stable/install/kernel_install.html

在 Anaconda Navigator -> Enviroments -> Play 按钮 -> Open Terminal -> conda install keras 中安装包

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense,Dropout,Activation, Flatten, Conv2D, MaxPooling2D

These two import statements worked for me.这两个导入语句对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jupyter Notebook ModuleNotFoundError->没有名为'sql'的模块 - Jupyter Notebook ModuleNotFoundError --> No module named 'sql' ModuleNotFoundError:Jupyter Notebook 上没有名为“_tkinter”的模块 - ModuleNotFoundError: No module named '_tkinter' on Jupyter Notebook ModuleNotFoundError:在jupyter笔记本python中没有名为“可视化”的模块 - ModuleNotFoundError: No module named 'visualization' in jupyter notebook python Jupyter 笔记本:ModuleNotFoundError:没有名为“scipy”的模块 - Jupyter notebook: ModuleNotFoundError: No module named 'scipy' (Jupyter Notebook) ModuleNotFoundError: No module named 'pandas' - (Jupyter Notebook) ModuleNotFoundError: No module named 'pandas' ModuleNotFoundError:没有名为“pandas”的模块(jupyter notebook) - ModuleNotFoundError: No module named 'pandas' (jupyter notebook) ModuleNotFoundError:Jupyter Notebook 中没有名为“tensorflow”的模块 - ModuleNotFoundError: No module named 'tensorflow' In Jupyter Notebook 进入 Jupyter 笔记本:ModuleNotFoundError:没有名为“podman”的模块 - Getting in Jupyter notebook: ModuleNotFoundError: No module named 'podman' ModuleNotFoundError:Jupyter Notebook 上没有名为“pandas”的模块 - ModuleNotFoundError: No module named 'pandas' on Jupyter Notebook ModuleNotFoundError:jupyter 笔记本中没有名为“deeppavlov”的模块 - ModuleNotFoundError: No module named 'deeppavlov' in jupyter notebook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM