无法使用 twine 上传到 PyPI ("invalid command")

Can't upload to PyPI with twine ("invalid command")

我正在尝试使用 twine 将我的包上传到 PyPI。 我已经按照 official documentation 进行操作,但我在这一步停止了: twine upload dist/* 我之前的任何步骤都没有错误,我一直在使用 python3 而不是 python (所以之前的所有步骤都使用了 python3 或 pip3)

$ twine upload dist/*
Invalid command: upload

$ which twine
/usr/local/bin/twine

$ twine --version
Twine version 1.0.1

$ which python3
/usr/local/bin/python3

原来我安装了不同的麻线,this one,导致了错误。如何删除当前安装的 twine 并安装正确的 PyPi Twine?

更新 1 我已经删除了其他版本的麻线。我 运行 pip3 install twine 它给出了很多已经满足的要求行:twine in /Users/..... 但是如果我 运行 twine --version 我得到 -bash: twine: command not found

你的 $PATH 中是否有其他匹配 twine 的东西,所以它可能使用这个而不是 PyPi Twine?

$PATH 从头到尾搜索,第一个匹配的可执行文件是 运行。因此 $PATH 开头的目录优先于后面的目录。