Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python导入中出错_Python_Python 3.x_Package - Fatal编程技术网

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 
您可以通过
文件->路径浏览器
在空闲状态下检查
系统路径