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

9.7k Views Asked by At

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:

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). Also there is a different error when I use the register command in the virtualenv, I get this:

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

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='[email protected]',
      license='MIT',
      packages=['Utilitarian'],
      zip_safe=False)

Please help. Thank you.

1

There are 1 best solutions below

2
On

You need to create .pypirc file by yourself in your HOME directory

touch ~/.pypirc

this file should contain the following code, put you login and password from 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>

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

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):

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

after it you can upload your package to pip with the following command

twine upload dist/*