I have a virtual env that I created with Anaconda. When activated I can start a python3 shell and import the keras library and I get the following warning but otherwise it seems to work.
/home/ryan/anaconda3/envs/spyderudemy/lib/python3.6/site-packages/h5py/init.py:36: 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
. from ._conv import register_converters as _register_converters Using TensorFlow backend.
Now if in my terminal I have the virtual env activated and I start the Spyder IDE from that terminal I'm unable to access the keras library in the IPython console. Specifically the import that is causing me problems is:
from keras.models import Sequential
The output in the IPython shell is:
ModuleNotFoundError: No module named 'keras'
I'm using Ubuntu 16.04 and when I start Spyder this is displayed at the top of the console:
Python 3.6.5 |Anaconda custom (64-bit)| (default, Apr 26 2018, 13:46:40)
From my normal bash terminal if I execute
python3 -c 'import sys, pprint; pprint.pprint(sys.path)'
I get:
['', '/home/ryan/anaconda3/envs/spyderudemy/lib/python36.zip', '/home/ryan/anaconda3/envs/spyderudemy/lib/python3.6', '/home/ryan/anaconda3/envs/spyderudemy/lib/python3.6/lib-dynload', '/home/ryan/anaconda3/envs/spyderudemy/lib/python3.6/site-packages']
Even though I thought Tensorflow should be included in the Anaconda packages, since it wasn't working, I installed it in the env using pip3 like so:
sudo pip3 install --upgrade tensorflow
I used sudo because I was getting permission errors and I thought the output looked okay:
The directory '/home/ryan/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/ryan/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting tensorflow Downloading https://files.pythonhosted.org/packages/6d/dc/464f59597a5a8282585238e6e3a7bb3770c3c1f1dc8ee72bd5be257178ec/tensorflow-1.8.0-cp35-cp35m-manylinux1_x86_64.whl (49.1MB) 100% |████████████████████████████████| 49.1MB 33kB/s Collecting tensorboard<1.9.0,>=1.8.0 (from tensorflow) Downloading https://files.pythonhosted.org/packages/59/a6/0ae6092b7542cfedba6b2a1c9b8dceaf278238c39484f3ba03b03f07803c/tensorboard-1.8.0-py3-none-any.whl (3.1MB) 100% |████████████████████████████████| 3.1MB 466kB/s Collecting wheel>=0.26 (from tensorflow) Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB) 100% |████████████████████████████████| 51kB 3.3MB/s Collecting numpy>=1.13.3 (from tensorflow) Downloading https://files.pythonhosted.org/packages/43/17/cd9fa14492dbef2aaf22622db79dba087c10f125473e730cda2f2019c40b/numpy-1.14.5-cp35-cp35m-manylinux1_x86_64.whl (12.1MB) 100% |████████████████████████████████| 12.1MB 131kB/s Collecting gast>=0.2.0 (from tensorflow) Collecting protobuf>=3.4.0 (from tensorflow) Downloading https://files.pythonhosted.org/packages/11/c4/8a35f5af5f26040ae7f3d521875e43429d2955d598fa3f2d0b6b88133bb1/protobuf-3.6.0-cp35-cp35m-manylinux1_x86_64.whl (7.1MB) 100% |████████████████████████████████| 7.1MB 223kB/s Requirement already up-to-date: six>=1.10.0 in /usr/local/lib/python3.5/dist-packages (from tensorflow) Collecting termcolor>=1.1.0 (from tensorflow) Collecting absl-py>=0.1.6 (from tensorflow) Collecting astor>=0.6.0 (from tensorflow) Downloading https://files.pythonhosted.org/packages/b2/91/cc9805f1ff7b49f620136b3a7ca26f6a1be2ed424606804b0fbcf499f712/astor-0.6.2-py2.py3-none-any.whl Collecting grpcio>=1.8.6 (from tensorflow) Downloading https://files.pythonhosted.org/packages/c6/b8/47468178ba19143e89b2da778eed660b84136c0a877224e79cc3c1c3fd32/grpcio-1.12.1-cp35-cp35m-manylinux1_x86_64.whl (9.0MB) 100% |████████████████████████████████| 9.0MB 182kB/s Collecting markdown>=2.6.8 (from tensorboard<1.9.0,>=1.8.0->tensorflow)
Downloading https://files.pythonhosted.org/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl (78kB) 100% |████████████████████████████████| 81kB 3.8MB/s Collecting html5lib==0.9999999 (from tensorboard<1.9.0,>=1.8.0->tensorflow) Collecting bleach==1.5.0 (from tensorboard<1.9.0,>=1.8.0->tensorflow) Downloading https://files.pythonhosted.org/packages/33/70/86c5fec937ea4964184d4d6c4f0b9551564f821e1c3575907639036d9b90/bleach-1.5.0-py2.py3-none-any.whl Collecting werkzeug>=0.11.10 (from tensorboard<1.9.0,>=1.8.0->tensorflow) Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB) 100% |████████████████████████████████| 327kB 1.8MB/s Collecting setuptools (from protobuf>=3.4.0->tensorflow) Downloading https://files.pythonhosted.org/packages/7f/e1/820d941153923aac1d49d7fc37e17b6e73bfbd2904959fffbad77900cf92/setuptools-39.2.0-py2.py3-none-any.whl (567kB) 100% |████████████████████████████████| 573kB 1.5MB/s Installing collected packages: markdown, numpy, html5lib, wheel, setuptools, protobuf, bleach, werkzeug, tensorboard, gast, termcolor, absl-py, astor, grpcio, tensorflow Found existing installation: numpy 1.13.3 Uninstalling numpy-1.13.3: Successfully uninstalled numpy-1.13.3 Found existing installation: html5lib 0.999 Uninstalling html5lib-0.999: Successfully uninstalled html5lib-0.999 Found existing installation: wheel 0.29.0 Uninstalling wheel-0.29.0: Successfully uninstalled wheel-0.29.0 Found existing installation: setuptools 20.7.0 Uninstalling setuptools-20.7.0: Successfully uninstalled setuptools-20.7.0 Found existing installation: protobuf 3.4.0 Uninstalling protobuf-3.4.0: Successfully uninstalled protobuf-3.4.0 Successfully installed absl-py-0.2.2 astor-0.6.2 bleach-1.5.0 gast-0.2.0 grpcio-1.12.1 html5lib-0.9999999 markdown-2.6.11 numpy-1.14.5 protobuf-3.6.0 setuptools-39.2.0 tensorboard-1.8.0 tensorflow-1.8.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.31.1 You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
If anyone has any advice for me regarding this issue I'd be eternally grateful.