制造模块:

方法一:

1、

mkdir /xx
cd /xx

2、
文件包含:

  

模块名.py 
    setup.py
setup.py内容如下:
#!/usr/bin/env python
from distutils.core import setupsetup(
    name = "nester",
    version = '1.0.0',
    py_modules = ['nester'],
    author = 'xiaofan',
    description = "a module exp",)

3、
执行shell命令:

python setup.py sdist  (构建发布功能)
python setup.py install  (安装到本地)

4、
在python中就可以导入xx啦:

>>> import 模块(不需要.py)

 

方法二:

>>> import sys
>>> for line in sys.path:
...     print(line)
... /usr/lib64/python26.zip
/usr/lib64/python2.6
/usr/lib64/python2.6/plat-linux2
/usr/lib64/python2.6/lib-tk
/usr/lib64/python2.6/lib-old
/usr/lib64/python2.6/lib-dynload
/usr/lib64/python2.6/site-packages
/usr/lib/python2.6/site-packages
/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info

在上面的任意一路径下写自己的模块。