I tried to import the Keras library in Spyder but it throws an error:
Traceback (most recent call last):
File "<ipython-input-8-c74e2bd4ca71>", line 1, in <module>
import keras
ModuleNotFoundError: No module named 'keras'
Then I created a virtual environment and installed Keras in that:
cd virtualenv/
virtualenv -p python3.5 py-keras
source py-keras/bin/activate
pip install -q -U pip setuptools wheel
pip install keras
If I'm editing in that virtual env with the terminal I can import Keras successfully, whereas in Spyder it still throws the same error.
If you have anaconda (as Sypder is a part of it) . Why don't you do
conda install keras
on terminal. It install and works without any problem on spyder.
Did you try starting Spyder from the virtualenv as well? You can activate your virtualenv as you did:
source py-keras/bin/activate
Then start spyder with the appropriate command from the command line:
spyder
You will have the keras installed by using either ways. conda install keras from conda command prompt OR pip install keras from command prompt pointing to python36_64\\Scripts. but, the only extra step you need to do to get that realized in Spyder console is close the Spyder console and launch it again through Anaconda Navigator. Use start > Anaconda Navigator -> Spyder. You should be able to import keras.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.