简体   繁体   中英

python pip install calling module by name in terminal

I've noticed that for some packages, for example, ipython and termdown , after I've successfully installed them with pip install , they can be immediately invoked from the terminal. eg:

$ termdown 100

I understand that the primary file within these packages are operated by the #! shebang line and hence callable, however, where in the python directory are the hook that allowed them to become callable stored? eg a /bin folder where everything can be invoked from the terminal? Or is there some other mechanism like PATH in play? Thanks!

Generally when a Python package is installed via pip , setuptools , etc. two mechanisms can be invoked within the packages setup.py file to produce a CLI executable command:

The scripts keyword argument and the console_scripts entry point.

Usually a symlink is created within /usr/local/bin that points back to the installed package.

Python Packaging | Command Line Scripts

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