Jupyter can't find keras' module

2020-04-03 06:05发布

I have installed Tensorflow and Keras by Anaconda (on Windows 10), I have created an environment where I am using Python 3.5.2 (the original one in Anaconda was Python 3.6). When I try to execute import keras as ks, I get ModuleNotFoundError: No module named 'keras'.

I have tried to solve this issue by sys.path.append(C:\\Users\\ ... \\Anaconda3\\python.exe)

with both notebook and console, but I continue to get the same error.

How could I solve this issue?

8条回答
Viruses.
2楼-- · 2020-04-03 07:01

Acually, I did this command pip install keras and sudo -H pip3 install keras and pip3 install keras. None of them worked. I added the following command and everything worked like a charm: pip install Keras. Yes a capital 'K'

查看更多
够拽才男人
3楼-- · 2020-04-03 07:02

Here's how I solved this problem.

First, the diagnosis. When I run which python in a terminal window on my Mac (the same terminal I used to launch jupyter, I get /Users/myusername/.conda/envs/myenvname/bin/python, but when I run the same command from a terminal within Jupyter, I get /usr/bin/python. So Jupyter isn't using the correct python executable; the version it's using doesn't have any of my packages installed.

But which jupyter returns /usr/bin/jupyter; it's using a version of jupyter that isn't coming from within my conda environment. I ran conda install jupyter and now which jupyter returns /Users/myusername/.conda/envs/myenvname/bin/jupyter (for some reason I had to restart the terminal window for this to take effect.) Then if I relaunch jupyter notebook, the notebook is using the correct version of Python and I have access to all my installed conda packages.

查看更多
登录 后发表回答