简体   繁体   English

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

[英]My home does not have .pypirc file which is giving me an error while registering the python package to PyPI

I am using ubuntu and I have created a python package and it is ready to register on PyPI but when I use python setup.py register it is showing an error like this: 我正在使用ubuntu,我已经创建了一个python包,它已准备好在PyPI上注册但是当我使用python setup.py register它显示如下错误:

Server response (410): This API is no longer supported, instead simply upload the file.

I know that this is the error of not finding the .pypirc file but I don't know how to fix this because my home does not have the .pypirc file.Can't we just create the pypirc file?(just asking). 我知道这是找不到.pypirc文件的错误,但我不知道如何解决这个问题因为我的家没有.pypirc文件。我们不能只创建pypirc文件吗?(只是问)。 Also there is a different error when I use the register command in the virtualenv, I get this: 当我在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)

and here is my setup.py file 这是我的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)

Please help. 请帮忙。 Thank you. 谢谢。

You need to create .pypirc file by yourself in your HOME directory 您需要在HOME目录中自己创建.pypirc文件

touch ~/.pypirc

this file should contain the following code, put you login and password from pypi 这个文件应该包含以下代码,从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>

Because you put you login and password into this file, you may want to change it's permission so that only you can read and write it. 因为您将登录名和密码放入此文件中,您可能希望更改其权限,以便只有您可以读取和写入它。

chmod 600 ~/.pypirc

And after it you can try to register your package, by the way I hightly recommend you using twine library to load your package, just install it 在它之后,您可以尝试注册您的包装,顺便提一下我建议您使用twine库来装入包装,只需安装它

pip install twine

Then make a distribution for your package 然后为您的包进行分发

python setup.py install

This command will create a dist folder with your module packed inside then register your project (if necessary): 此命令将创建一个dist文件夹,其中包含您的模块,然后注册您的项目(如有必要):

twine register dist/example-project-x.y.z.tar.gz

after it you can upload your package to pip with the following command 之后,您可以使用以下命令将包上传到pip

twine upload dist/*

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM