简体   繁体   中英

How to install Python script on Windows?

I wrote a small command-line utility in Python. I also created setup.py script:

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

config = {
    'name': 'clitool',
    'author': 'aa',
    'author_email': 'ww',
    'version': '1.0-rc',
    'install_requires': ['nose'],
    'packages': [],
    'scripts': ['clitool']
}

setup(**config)

When I call:

setup.py install

my script copied to C:\\Python34\\Scripts path. This path is in the PATH variable, but Windows when I try to start my clitool from some direcory writes:

"clitool" not recognized as an internal or external command

It's possible to run from any directory, only the files from C:\\Python34\\Scripts with the exe extension.
But my script is copied as a file without extension and in Windows it does not run it.

Solution:

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

config = {
    'name': 'clitool',
    'author': 'aa',
    'author_email': 'ww',
    'version': '1.0-rc',
    'install_requires': ['nose'],
    'packages': [],    
    'entry_points' : {
        'console_scripts': ['clitool=clitool.cli:main'],
    }
}

setup(**config)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM