Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

385
Views
Import keras.datasets not working

I have keras installed on my linux machine, but when I try to import a dataset from the keras.datasets I get an error that it cannot find it.

So for example:

from keras.datasets import mnist

I get the error

ImportError: No module named keras.datasets

I installed keras using pip install and it installed successfully.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Do you have keras.py or keras.pyc in the current working directory? If so, this will mess up the imports. Try renaming the file and/or deleting keras.pyc.

over 4 years ago · Santiago Trujillo Report

0

Indeed the problem was that I had multiple versions of Python.

Removing Anaconda Python and installing all libraries using pip / apt-get instead of conda solved my problem.

I found this to be true but it is not necessary to delete anaconda. I had the same issue but with multiple python versions. However, i created an environment that only used the Anaconda version (while in that environment). In terminal (on mac and other suitable terminals), type/copy

conda create -n dataweekends python=2.7 pandas scikit-learn jupyter matplotlib

dataweekends is simply the name of the environment you created. To access this, just use the command

source activate dataweekends

Be mindful that you might (probably) have to reinstall dependencies once in that new environment.

I got this trick from here "https://www.dataweekends.com/blog/2017/03/09/set-up-your-mac-for-deep-learning-with-python-keras-and-tensorflow"

I would also recommend setting up different environments for each project you do in python.

over 4 years ago · Santiago Trujillo Report

0

Thanks to the comment from Selcuk which got me on the right track.

Indeed the problem was that I had multiple versions of Python. I followed some online instructions to installing Keras which recommended installing MiniConda/Conda/Anaconda which is its own version of python. So I had two Python2.7 versions installed:

  • Normal Linux Python 2.7
  • Anaconda Python 2.7

Removing Anaconda Python and installing all libraries using pip / apt-get instead of conda solved my problem.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!