Reputation: 1154
I'm using Anaconda, and I have already installed TensorFlow
which works fine. Now I want to install keras
. Here what i did:
activate tensorflow
pip install keras
installation seems to be successful. after that i run
idle
and then to test correctness, i run this:
from keras.models import Sequential
and receive following error:
Warning (from warnings module): File "C:\Users\ccc\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\h5py__init__.py", line 36 from ._conv import register_converters as _register_converters FutureWarning: Conversion of the second argument of issubdtype from
float
tonp.floating
is deprecated. In future, it will be treated asnp.float64 == np.dtype(float).type
. Using TensorFlow backend.
I thought maybe this is just a warning, and then I run
jupyter notebook
and then try to import stuff. Error is this:
import seaborn as sns
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegressionCV
from keras.models import Sequential
from keras.layers.core import Dense, Activation
from keras.utils import np_utils
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-4f6dad112f73> in <module>()
5 from sklearn.linear_model import LogisticRegressionCV
6
----> 7 from keras.models import Sequential
8 from keras.layers.core import Dense, Activation
9 from keras.utils import np_utils
>
> ModuleNotFoundError: No module named 'keras'
EDIT i've done cd to folder where I want to do my project.
print(sys.path)
in idle returns this:
['', 'C:\\Users\\smuminov\\Desktop\\UC\\Spring-2018\\CS504\\Project\\Prediction',
'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\envs\tensorflow\Scripts', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\envs\tensorflow\python35.zip', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\envs\tensorflow\DLLs', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\envs\tensorflow', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\uritemplate-3.0.0-py3.5.egg']
in jupyter in returns this:
['', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\python36.zip', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\DLLs', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\lib', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\lib\site-packages', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\lib\site-packages\win32', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\lib\site-packages\win32\lib', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\lib\site-packages\Pythonwin', 'C:\Users\smuminov\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\extensions', 'C:\Users\smuminov\.ipython']
They are different. Should they be the same?
Upvotes: 1
Views: 950
Reputation: 9481
Probably your python path is messed up. The message you are getting in 'idle' is just a warning you can ignore it for now. But the message you getting in your jupyter notebooks is a real error that you need to fix.
Try running the following code both in your idle environment and in Jupyter notebook. Do it before you import Keras
import sys
print sys.path
Then compare results. Probably jupyter is not picking up your virtual environment.
Continuing based on your test results:
Looks like you running Idle from virtualenv that you created called 'tensorflow', but you are running jupyter from regular anaconda environment.
If you jupyter is simply installed as a module in Anaconda environmnet. You can just install it again into your tensorflow virtual env by running the following commands
activate tensorflow
pip install jupyter
Then run
jupyter-notebook
This should fix your issue. Make sure to print out sys.path to double check
Upvotes: 3