无法将包上传到 PyPI:410 Gone
- 2025-04-10 09:46:00
- admin 原创
- 45
问题描述:
在pypi.python.org 迁移到 pypi.org之后,我尝试使用以下命令将包上传到 PyPI 时收到错误:
python2.7 setup.py sdist upload
错误信息是:
Upload failed (410): Gone (This API has been deprecated and removed from legacy PyPI in favor of using the APIs available in the new PyPI.org implementation of PyPI (located at https://pypi.org/). For more information about migrating your use of this API to PyPI.org, please see https://packaging.python.org/guides/migrating-to-pypi-org/#uploading. For more information about the sunsetting of this API, please see https://mail.python.org/pipermail/distutils-sig/2017-June/030766.html)
我查看了消息中提到的解决方案,然后谷歌了一下。不幸的是,我找到的解决方案不起作用,包括更新我的本地~/.pypirc
文件。像这样:
[distutils]
index-servers =
pypi
[pypi]
repository:https://pypi.python.org/pypi or repository:https://upload.pypi.org/legacy/
username:yourusername
password:yourpassword
我仍然收到相同的错误消息。我该怎么办?
解决方案 1:
升级到最新的 pip 和 setuptools;安装 twine:
pip install -U pip setuptools twine
编辑~/.pypirc
并注释掉或删除repository
:
[pypi]
#repository:https://pypi.python.org/pypi
使用 twine 将模块从包含模块源、setup.py 和其他文件的文件夹内上传到 pypi:
python setup.py sdist
twine upload dist/*
请参阅https://packaging.python.org/guides/migrating-to-pypi-org/#uploading
解决方案 2:
如果您正在寻找旧版解决方案,请尝试将您的~/.pypirc
文件更新至此
[distutils]
index-servers =
pypi
[pypi]
repository: https://upload.pypi.org/legacy/
username: username
password: password
并且运行
python setup.py sdist upload -r pypi
不确定它是否会立即起作用。因为我做了多件事来让它工作,例如
更新 python 和 python3(我仍然使用 2.7.12 和 3.5.2)
twine
如果你的系统还没有安装更新
pip
,setuptools
并twine
根据博士的建议也
pip3 install -U pip setuptools twine
可能有帮助
解决方案 3:
我建议使用麻线。
只需安装它:
pip install twine
只需这样做:
twine upload dist/*
注意:从项目的根目录执行此操作
扫码咨询,免费领取项目管理大礼包!