未找到麻线(-bash:麻线:未找到命令)

twine not found (-bash: twine: command not found)

我正在尝试使用 twine 在 pypi 上发布我的第一个 python 包(当然会先在 test-pypi 上添加)。

我遵循 https://packaging.python.org/tutorials/packaging-projects/ 上的官方指南。

但由于某种原因,找不到或未正确安装 twine。

我安装 twine 使用:

pip install twine

"pip list" 表示 twine 已安装在 pip 上。

在我升级​​ twine 和所有东西之后,当我尝试 运行 时:

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

然后说根本找不到麻线:

-bash: twine: command not found . 

我的系统是 mac(high sierra),我使用的是 conda 的 python2.7。 pip 也配置为 conda python:

>>pip -V 
>>pip 10.0.1 from /anaconda2/lib/python2.7/site-packages/pip (python 2.7)

非常感谢您的帮助。

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

基于@hoefling 评论运行

pip show twine

这将列出属于 twine 包的所有文件。它将输出如下内容:

Name: twine
Version: 1.12.1
Summary: Collection of utilities for publishing packages on PyPI
Home-page: https://twine.readthedocs.io/
Author: Donald Stufft and individual contributors
Author-email: donald@stufft.io
License: Apache License, Version 2.0
Location: /Users/hakuna.matata/.local/lib/python3.6/site-packages
Requires: pkginfo, readme-renderer, tqdm, requests, requests-toolbelt, setuptools
Required-by: 

注意 Files 下的第一个文件是 ../../../bin/twineLocation: /Users/hakuna.matata/.local/lib/python3.6/site-packages。当然,您的用户名将替换 'hakuna.matata'

这将导致 /Users/hakuna.matata/.local/bin 处的可执行程序包路径,您可以将其添加到 .bash_profile 作为 export PATH="/Users/hakuna.matata/.local/bin:$PATH"

然后,要么重新启动终端,要么

source ~/.bash_profile