python - 我的家没有 .pypirc 文件,这在将 python 包注册到 PyPI 时给我一个错误

标签 python ubuntu pypi python-packaging pypiserver

我正在使用 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)

请帮忙。谢谢。

最佳答案

你需要在你的HOME目录下自己创建.pypirc文件

touch ~/.pypirc

这个文件应该包含以下代码,把你的登录名和密码从pypi

[distutils]
index-servers =
    pypi
    pypitest

[pypitest]
repository = https://test.pypi.org/legacy/
username = <your username>
password = <your password>

[pypi]
repository = https://upload.pypi.org/legacy/
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/*

关于python - 我的家没有 .pypirc 文件,这在将 python 包注册到 PyPI 时给我一个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44892233/

相关文章:

python - wx.TextCtrl 和 wx.Validator

linux - 套接字连接在关闭后仍会保持一段时间

python - 在 Linux Ubuntu 上无法打开 Scrapy

python - 如何修复错误 : Could not find a version that satisfies the requirement for uncompyle6-3. 7.4-py3.8?

python - 名称 'times' 在全局声明之前使用 - 但它已声明!

python - 在没有循环的情况下向numpy数组中的所有奇数或偶数索引元素添加一个数字

python - ValueError : Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 196, 196, 3),调整大小后发现 shape=(None, 196, 3)

java - 压缩提取的 Jar 文件

python - 无法使用 pipelinenv 安装 PyPi 库

python - 如何从 Github 工作流程访问环境 secret ?