pip:为什么 twine 命令有时不显示

pip: why doesn't twine command show up sometimes

我使用用户标志(用户方案,根据文档)安装了 twine:

pip install --user twine

但我不能将它用作命令。例如如果我这样做:

twine --version

它给了我(这很明显):

-bash: twine: command not found

我阅读了 类似 post,但找不到满意的答案(答案未被接受)。

我知道我可以使用:

python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*

根据其中一个答案。

但是,我的问题是为什么它没有出现?

我检查了麻线 setup.py,发现它使用 entry_points(这有助于设置 twine command)。在我的假设中,setup.py 被忽略,因为它 pip 在安装(或下载包)期间使用 wheel 而不是 sdist

对于命令

twine --version

shell 尝试在 $PATH 中查找 twine 二进制文件或脚本。如果找不到脚本,它会发出错误 -bash: twine: command not found。这意味着 pip 已将 twine 安装到不在 $PATH 中的目录中。使用命令

找出pip安装它的位置
pip show --files twine

并将目录添加到 $PATH

对于命令

python3 -m twine --version

shell 查找 python3python3 -m 查找 模块 twine,而不是脚本。 python3 -msys.path 中查找模块,完全不同的搜索路径。