我正在使用ubuntu,我已经创建了一个python包,它已准备好在PyPI上注册,但是当我使用python setup.py register
时,它显示如下错误:
Server response (410): This API is no longer supported, instead simply upload the file.
我知道这是找不到.pypirc文件的错误,但我不知道如何解决这个问题,因为我的家里没有.pypirc文件。我们只是创建了pypirc文件?(只是问)。当我在virtualenv中使用register命令时也会出现不同的错误,我明白了:
Server response (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)
这是我的setup.py文件
from setuptools import setup
setup(name='Utilitarian',
version='0.1',
description='little description',
url='https://github.com/Shivams334/Utilitarian.git',
author='Shivam Sharma',
author_email='shivams334@gmail.com',
license='MIT',
packages=['Utilitarian'],
zip_safe=False)
请帮忙。谢谢。
答案 0 :(得分:3)
您需要自己在.pypirc
目录
HOME
文件
touch ~/.pypirc
此文件应包含以下代码,为您提供pypi
的登录名和密码[distutils]
index-servers =
pypi
pypitest
[pypitest]
repository = https://testpypi.python.org/pypi
username = <your username>
password = <your password>
[pypi]
repository = https://pypi.python.org/pypi
username = <your username>
password = <your password>
因为您将登录名和密码添加到此文件中,您可能需要更改它的权限,以便只有您可以读取和写入。
chmod 600 ~/.pypirc
之后,您可以尝试注册您的包裹,顺便提一下我建议您使用twine库加载您的包裹,只需安装它
pip install twine
然后为您的包进行分发
python setup.py install
此命令将创建一个dist
文件夹,其中包含您的模块,然后注册您的项目(如有必要):
twine register dist/example-project-x.y.z.tar.gz
之后,您可以使用以下命令将包上传到pip
twine upload dist/*