简体   繁体   English

python中的模块链接是什么意思

[英]What does module linking in python mean

I'm not sure what exactly module linking means in python. 我不确定模块链接在python中到底意味着什么。 For example, in spacy issues, I see https://github.com/explosion/spaCy/issues/1523 . 例如,在spacy问题中,我看到https://github.com/explosion/spaCy/issues/1523

python -m spacy link jieba zh

How does this work? 这是如何运作的?

Most importantly, how I do ensure this happens in requirements.txt or somewhere programmatically? 最重要的是,如何确保这种情况发生在requirements.txt或以编程方式出现在某处?

"Module linking" is not the name of any concept in Python's module system. “模块链接”不是Python模块系统中任何概念的名称。 I don't know where you got the idea that "module linking" is a thing that exists, but it does not exist. 我不知道“模块链接”是存在的东西,但它不存在。 In the command line you're looking at, link refers to spaCy's link command , which has nothing to do with Python modules. 在您正在查看的命令行中, link是指spaCy的link命令 ,它与Python模块无关。

One potentially could say that "module linking" might refer to the actions taken by a linker during the process of compiling an extension module. 可能会说“模块链接”可能是指链接器在编译扩展模块的过程中采取的动作。 This is not a commonly referred to step in usual Python development, even when working with extension modules (because the actions of the linker are generally implicit in some other compiler tool chain, and rarely treated as an isolated step, though in theory could be). 即使在使用扩展模块时,这也不是通常的Python开发中通常提到的步骤(因为链接器的操作通常在其他一些编译器工具链中是隐式的,尽管理论上可以做到,但很少被视为孤立的步骤) 。

There is minimal discussion of eg linker options you might encounter at this Cython documentation page for one example of this topic in an extension module setting. 对于扩展模块设置中该主题的一个示例,在此Cython文档页面上几乎没有讨论过例如链接器选项。

Note that in the specific line of code you show, 请注意,在您显示的特定代码行中,

python -m spacy link jieba zh

the python -m spacy part indicates that the spaCy module will be invoked directly with the interpreter, as a script, rather than its usual usage (imported from some other module or script). python -m spacy部分指示spaCy模块将作为脚本而不是通常的用法(从其他模块或脚本导入)作为脚本直接由解释器调用。

The things following this, link jieba zh , are treated as space delimited arguments passed as sys.argv to the program defined by spaCy's script execution, so the meaning of link in this context is determined by whatever spaCy defines for processing that argument. link jieba zh后面的内容被视为由空格分隔的参数,该参数作为sys.argv传递给spaCy脚本执行所定义的程序,因此,在此上下文中, link的含义由spaCy定义的用于处理该参数的内容确定。

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

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