我已经查看了 SO 中已有的答案,但似乎对我没有任何帮助。
我正在按照python命令上传我的包(注意:我是新用户并且已经使用用户名和密码注册了帐户):
创建 setup.py:
from setuptools import setup
setup(
name='', # This is the name of your PyPI-package.
version='0.1', # Update the version number for new releases
scripts=[''] # The name of your script, and also the command you'll be using for calling it
)
打包脚本:
python setup.py sdist
注册账号:
python setup.py register
这提示我下面的消息(我选择第二个,因为我是新用户):
1. use your existing login,
2. register as a new user,
3. have the server generate a new password for you (and email it to you), or
4. quit
Your selection [default 1]:
上传包:
python setup.py sdist upload
尝试以下步骤后,我在上传时遇到错误:
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.
最佳答案
经过反复试验,我找到了简单的解决方案。另外,@hoefling 的回答帮助我解决了这些问题。
在 https://pypi.org/ 中注册为用户并使用问题中提到的注册帐户命令。
现在,三个神奇的步骤将解决这个问题。
pip install twine
python setup.py sdist
# This will ask for you username and password
twine upload dist/*
编辑:
如果你想升级你的包,只需按照以下简单的步骤:
- 删除
build
,dist
, 和<package name>.egg-info
根目录中的文件夹。 - 更改
setup.py
中的版本号文件。 - 再次创建分布。例如:
python setup.py sdist bdist_wheel
- 再次上传分发。例如:
twine upload dist/*
关于python - 无法在 https ://upload. pypi.org/legacy/中上传包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49787860/