艰苦学习Python:练习46安装模块

艰苦学习Python:练习46安装模块,python,python-2.7,Python,Python 2.7,中所需的测验要求读者安装模块/软件包。我不知道我创建的模块和脚本是否适合这个练习,也不知道安装包后如何正确调用它。任何关于脚本和模块交互动态或其目的的见解也将受到赞赏 以下是目录结构: setup.py: try: from setuptools import setup except ImportError: from distutils.core import setup config = { 'description': 'My Project', 'au

中所需的测验要求读者安装模块/软件包。我不知道我创建的模块和脚本是否适合这个练习,也不知道安装包后如何正确调用它。任何关于脚本和模块交互动态或其目的的见解也将受到赞赏

以下是目录结构:

setup.py:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'description': 'My Project',
    'author': 'John',
    'url': 'URL to get it at.',
    'download_url': 'Where to download it.',
    'author_email': 'john@',
    'version': '0.1',
    'install_requires': ['nose'],
    'packages': ['ex47package'],
    'scripts': ['bin/ex47_script.py'],
    'name': 'ex47'
}

setup(**config)
ex47_module.py:

def explainIt():
    print "root_package"
    print "\tsetup.py"
    print "\tbin: a standard place to put scripts that are run on the command line, \
not a place to put modules."
    print"\t\tmyScipt.py"

    print "\tdocs"
    print "\ttests"
    print "\t\t__init__.py : tells Python that this directory is indeed a package; can be blank"
    print "\tmyPackage: the folder containing your Python code;\
should be the name you specify to 'packages' below"
    print "\t\t__init__.py : tells Python that this directory is indeed a package; can be blank"
    print "\t\tmyModule.py : your actual code; name doesn't matter"
    print "\nto install: python setup.py install"
    print "to uninstall: pip uninstall (name from setup.py)"
ex47_script.py:

#!/usr/bin/env python

print "This is the script in the bin directory"
xxx = raw_input("Enter some stuff to print: ")
print xxx
在我运行python setup.py安装后,ex47_script.py安装在

/usr/local/share/python

ex47-0.1-py2.7.egg安装在

/usr/local/lib/python2.7/site-packages