Python导入中出错
我正处于学习阶段,在导入Python导入中出错,python,python-3.x,package,Python,Python 3.x,Package,我正处于学习阶段,在导入import 我已经创建了一个名为test的模块,文件夹中有我的test.py、setup.py和python.exe,在运行sdist和install之后,我在build&dist文件夹中得到了MANIFEST文件、build、lib 现在,我尝试在空闲状态下使用我的模块,并产生以下结果 >>> import test >>> movies = ["1","2", ["3", "4", ["5", "6"]]] >>>
import
我已经创建了一个名为test的模块,文件夹中有我的test.py、setup.py和python.exe,在运行sdist和install之后,我在build&dist文件夹中得到了MANIFEST文件、build、lib
现在,我尝试在空闲状态下使用我的模块,并产生以下结果
>>> import test
>>> movies = ["1","2", ["3", "4", ["5", "6"]]]
>>> test.lol ()
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
test.lol ()
AttributeError: 'module' object has no attribute 'lol'
我使用Windows7机器和Python3.2您正在从标准库导入
测试
模块,而不是您自己的测试
模块
为了让Python能够找到模块,它们必须按照sys.path
列表中定义的路径定位,例如:
import sys
# insert the path to the beginning of the list:
sys.path.insert(0, '/path/to/my/test/module/directory')
# now Python importing system will search the directory defined above
# before scanning the standard library dirs.
import test
您可以通过
文件->路径浏览器
在空闲状态下检查系统路径
您正在从标准库导入测试
模块,而不是您自己的测试
模块
为了让Python能够找到模块,它们必须按照sys.path
列表中定义的路径定位,例如:
import sys
# insert the path to the beginning of the list:
sys.path.insert(0, '/path/to/my/test/module/directory')
# now Python importing system will search the directory defined above
# before scanning the standard library dirs.
import test
您可以通过文件->路径浏览器
在空闲状态下检查系统路径