0

Beginner here! I've successfully (I think) set up and installed all the required libraries for Deep Learning environment with Anaconda according to this post but now when I build the following code in SublimeText:

from numpy import loadtxt
from keras.models import Sequential
from keras.layers import Dense

it gives me the error:

ModuleNotFoundError: No module named 'keras'
[Finished in 1.8s with exit code 1]
[cmd: ['/Library/Frameworks/Python.framework/Versions/3.7/bin/python3', '-u', '/Users/Nik/Desktop/keras_first_network.py']]
[dir: /Users/Nik/Desktop]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

I thought it was a compatibility issue so i downgraded Python using conda install python=3.6.4 but the error keep coming up. What's happening?

I've tried downgrading Python to a lower version. When I run the above code directly in Python from the terminal there's no error.

cccnrc
  • 1,195
  • 11
  • 27
  • What operating system are you using? Are you sure you didn't `pip install keras` using the default Python 2 that comes with the system? What happens if you do `python3 -c "import keras"` in a terminal? Are you using a conda virtual environment? – Mihai Chelaru Aug 04 '19 at 02:01
  • Thanks for response! I'm using macOS mojave. so i've now tried python3 -c "import keras" and it said it wasn't there, so i'm then assuming that pip install keras did install using Python 2 and not 3.X. I tried it with pip3 install keras and when I run the script in Sublime it says "using tensorflow as backend" so I'm assuming it works now. HOWEVER, this has now caused another problem where it says ModuleNotFoundError: No module named 'tensorflow' . I don't think I've created a virtual environment? Do I have to? I'm pretty new to this so excuse the lack of knowledge re: venv haha – Nik Supatravanij Aug 04 '19 at 06:33
  • How did you install tensorflow? Since the keras import worked and all you can check the same way for tensorflow to see if you have it installed. That guide is somewhat outdated. – Mihai Chelaru Aug 04 '19 at 12:36
  • Solved! Did a reinstall of Python3 and SublimeText 3 according to https://www.sublimetext.com/docs/3/revert.html which solved my problem. Suspect it was just alot of mixed up pathways and pointing so had a hunch a reset would resolve which it did - thanks for the suggestions! – Nik Supatravanij Aug 04 '19 at 12:49
  • No problem. You might wish to post your solution as an answer in case someone else runs into the same problem. I for one didn't know about the sublime text revert option. – Mihai Chelaru Aug 04 '19 at 12:53

1 Answers1

0

Solved! Did a reinstall of Python3 and SublimeText 3 according to sublimetext.com/docs/3/revert.html which solved my problem. Suspect it was just alot of mixed up pathways and pointing so had a hunch a reset would resolve which it did