importTerror:无法导入名称“MNIST”

2024-05-15 03:38:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以pip安装所有其他包,如bumpy、sklearn等,但mnist包抛出如下错误。我一直在尝试使用sudo pip安装,但它也说

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


Tags: piptheinlibpackagessudositerequirement
4条回答

您正在尝试调用一个不存在的函数,例如

导入时间 睡眠时间(9)

这里它可以睡9分钟,但是如果你试着从模块调用模块

从时间导入时间 它将查找时间并找到一个名为time的函数,例如

时间,时间

在本例中,time函数是存在的,因此它将工作,但不是time.time,它将用作time

前:当前时间=时间.time 之后:当前时间=时间 (建议将其导入为不同的名称示例:from time import time as currentime)

因此,如果您试图调用模块中的函数,请重新查看名称 如果你想调用模块

导入mnist

或者如果模块内部有一个函数:from mnist import mnistno caps

正如@恐龙所指出的,python mnist和mnist是两个不同的包。对于python包python mnist,惟一的模块是loader。

如果将导入更改为:

from mnist.loader import MNIST

它应该有用。

注意^{}^{}是两个不同的包,它们都有一个名为mnist的模块。您需要的包是python-mnist。这样做:

pip install python-mnist

可能需要使用以下命令卸载mnist包:

pip uninstall mnist

那么您的import语句应该可以工作了。

您正在尝试调用一个不存在的函数,例如

导入时间 睡眠时间(9)

在这里它可以睡9分钟,但是如果你试图从模块调用模块

从时间导入时间 它将查找时间并找到一个名为time的函数,例如

时间,时间

在本例中,time函数是存在的,因此它将工作,但不是time.time,它将用作time

前:当前时间=时间.time 之后:当前时间=时间 (建议将其导入为不同的名称示例:from time import time as currentime)

因此,如果您试图调用模块中的函数,请重新查看名称 如果你想调用模块

导入mnist

或者如果模块内部有一个函数:from mnist import mnistno caps

相关问题 更多 >

    热门问题