<p>我联系了图书馆的开发者,他帮了我很多。我还应用了@phd在问题评论中提到的建议。完整的解决方案:</p>
<ol>
<li><p>将<code>/source</code>文件夹复制到<code>/python</code>文件夹中</p>
</li>
<li><p>编辑<code>/python/setup.py</code></p>
</li>
</ol>
<p>更改此项:</p>
<pre><code>c_ext = Extension("metaphoneptbr", ["metaphone_ptbrpy.c", join("..", "source", "metaphone_ptbr.c")])
setup(
name='Metaphone-ptbr',
version='1.17',
ext_modules=[c_ext],
include_dirs=[".", join("..", "source")]
)
</code></pre>
<p>为此:</p>
<pre><code>c_ext = Extension("metaphoneptbr", ["metaphone_ptbrpy.c", join("source", "metaphone_ptbr.c")])
setup(
name='Metaphone-ptbr',
version='1.17',
ext_modules=[c_ext],
include_dirs=[".", join("source")]
)
</code></pre>
<ol start=“3”>
<li>编辑<code>/python/metaphone_ptbrpy.c</code>:</li>
</ol>
<p>更改此项:</p>
<pre><code>#include "../source/metaphone_ptbr.h"
</code></pre>
<p>为此:</p>
<pre><code>#include "source/metaphone_ptbr.h"
</code></pre>
<ol start=“4”>
<li><p>替换<a href="https://pastebin.com/s911tDSi" rel="nofollow noreferrer">this</a>和<a href="https://pastebin.com/G4B77RDB" rel="nofollow noreferrer">this</a>的<code>/source/metaphone_ptbr.c</code>和<code>/source/metaphone_ptbr.h</code>文件</p>
</li>
<li><p>在<code>/python</code>文件夹中运行<code>python setup.py build</code>命令以生成项目,然后运行<code>pip install .</code>以完成安装</p>
</li>
</ol>
<p>要测试是否一切正常,只需运行以下命令:</p>
<pre><code>from metaphoneptbr import phonetic
print(phonetic('hello'))
</code></pre>
<p>PS:如果在执行上述命令时出现警告,只需将文件<code>/python/metaphone_ptbrpy.c</code>更改为<a href="https://pastebin.com/RHxEFSpL" rel="nofollow noreferrer">that</a>版本</p>
<ul>
<li>作者说,运行适用于Windows 10的Metaphone ptbr库所需的所有这些修改都将添加到存储库本身,但无论如何,我将与您分享解决方案是如何一步步进行的</李>
</ul>