无法将包上传到PyPI:410 Gone

时间:2017-07-20 06:43:44

标签: python pypi

pypi.python.org has been migrated to 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)

我查看了消息中提到的解决方案,然后用Google搜索了一下。不幸的是,我找到的解决方案无效,包括更新我的本地~/.pypirc文件。像这样:

[distutils]
index-servers =
    pypi

[pypi]
repository:https://pypi.python.org/pypi   or  repository:https://upload.pypi.org/legacy/
username:yourusername
password:yourpassword

我仍然收到相同的错误消息。我该怎么办?

3 个答案:

答案 0 :(得分:48)

升级到最新的pip和setuptools;安装麻线:

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

答案 1 :(得分:1)

如果您正在寻找旧版解决方案,请尝试将~/.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
  • 根据here is vim recipe的建议更新pipsetuptoolstwine
  • 同样pip3 install -U pip setuptools twine可能会有所帮助

答案 2 :(得分:0)

我建议使用麻线。

只需安装它:

pip install twine

简单地说:

twine upload dist/*
  

注意:从项目的根目录执行此操作