Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'MNIST'

I've able to pip install all other packages such as bumpy, sklearn etc. but mnist package throws me error as the following. I've been trying to use sudo pip install but it also says that

applesys$ pip install mnist
Requirement already satisfied: mnist in            /Users/applesys/anaconda3/lib/python3.5/site-packages
Requirement already satisfied: numpy in /Users/applesys/anaconda3/lib/python3.5/site-packages (from mnist)
applesys$ sudo pip install mnist
Password:
The directory '/Users/applesys/Library/Caches/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 '/Users/applesys/Library/Caches/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.
Requirement already satisfied: mnist in    /Users/applesys/anaconda3/lib/python3.5/site-packages
Requirement already satisfied: numpy in /Users/applesys/anaconda3/lib/python3.5/site-packages (from mnist)

import error

like image 506
jen007 Avatar asked Mar 13 '17 00:03

jen007


2 Answers

Note that python-mnist and mnist are two different packages, and they both have a module called mnist. The package you want is python-mnist. So do this:

pip install python-mnist

It might be necessary to uninstall the mnist package with:

pip uninstall mnist

Then your import statement should work.

like image 196
dinosaur Avatar answered Sep 16 '22 15:09

dinosaur


As noted by @dinosaur, python-mnist and mnist are two different packages. For python package, python-mnist, the only module is loader.

If you change the import to:

from mnist.loader import MNIST

It should work.

like image 33
JSymons7 Avatar answered Sep 20 '22 15:09

JSymons7