[英]Why I cannot import this module in Python with PTVS?
I am using VS2013 with PTVS. 我将VS2013与PTVS结合使用。
I can see the module datasets with dir(): 我可以使用dir()查看模块数据集:
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'datasets', 'pprint']
And datasets is a module: 数据集是一个模块:
>>> type(datasets)
<type 'module'>
But I cannot import the datasets module: 但是我无法导入数据集模块:
>>> import datasets
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named datasets
>>> from datasets import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named datasets
I did this because I don't want to save some typing of "datasets". 我这样做是因为我不想保存某些类型的“数据集”。 Why this error? 为什么会出现这个错误?
dir()
shows you the local variables. dir()
向您显示局部变量。 What this output means is that 1) you have a global variable named datasets
, and 2) it references a module. 此输出的意思是1)您有一个名为datasets
的全局变量,并且2)它引用了一个模块。 This would normally indicate that someone has imported it already in your scope. 通常,这表明有人已经将其导入了您的范围。 But import
itself does not operate on variables, it operates on modules directly. 但是import
本身并不对变量进行操作,而是直接对模块进行操作。
If I had to guess, the module is probably not actually named datasets
, it's just that someone did from .. import
or import .. as
. 如果我不得不猜测,该模块实际上可能不是命名datasets
,那只是有人from .. import
或以import .. as
。 You need to find out what the actual name of the module is. 您需要找出模块的实际名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.