简体   繁体   English

python pip在终端中按名称安装调用模块

[英]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. 我注意到,对于某些软件包,例如ipythontermdown ,在我使用pip install成功安装它们之后,可以立即从终端调用它们。 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? shebang行并因此可调用,但是,在python目录中的允许它们变为可调用的钩子存储在哪里? eg a /bin folder where everything can be invoked from the terminal? 例如/bin文件夹,可以从终端调用所有内容? Or is there some other mechanism like PATH in play? 还是有其他类似PATH机制在起作用? 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: 通常,当通过pipsetuptools等安装Python软件包时,可以在软件包setup.py文件中调用两种机制以生成CLI可执行命令:

The scripts keyword argument and the console_scripts entry point. scripts关键字参数和console_scripts入口点。

Usually a symlink is created within /usr/local/bin that points back to the installed package. 通常,在/usr/local/bin中创建一个符号链接,该符号链接指向已安装的软件包。

Python Packaging | ↳Python 封装| Command Line Scripts 命令行脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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