I have gone through already available answers in SO but nothing seems working for me.
I am following python commands to upload my package(Note: I am a new user and have registered the account with username and password):
Create setup.py:
from setuptools import setup setup( name='', # This is the name of your PyPI-package. version='0.1', # Update the version number for new releases scripts=[''] # The name of your script, and also the command you'll be using for calling it ) Package the script:
python setup.py sdist Register the account:
python setup.py register This prompted me below message(I choose 2nd as I am new user):
1. use your existing login, 2. register as a new user, 3. have the server generate a new password for you (and email it to you), or 4. quit Your selection [default 1]: Upload the package:
python setup.py sdist upload After trying steps I got the error while uploading:
Upload failed (403): Invalid or non-existent authentication information. error: Upload failed (403): Invalid or non-existent authentication information. 3 Answers
Answers 1
After a lot of trial and error, I found the simple solution. Also, @hoefling answer helps me to solve them.
Register as a user in https://pypi.org/ and use register account command which mentioned in the question.
Now, Three magic steps which will resolve the issue.
pip install twine python setup.py sdist twine upload dist/* //It will ask you to enter username and password Answers 2
First of all, note that register is deprecated and not necessary anymore. When trying to register a package on PyPI, you should get a message:
Server response (410): This API is no longer supported, instead simply upload the file. Just skip the register step and proceed with the uploading.
distutils/setuptools
Create a file $HOME/.pypirc with the contents:
[distutils] index-servers = pypi [pypi] username: <username> password: <password> and repeat the upload:
$ python setup.py sdist upload Thing is, the distutils' upload subcommand doesn't provide an option to enter the credentials from command line, instead completely relying on the .pypirc file.
twine
If storing credentials in plain text format is not your thing, twine provides a possibility of entering credentials from command line. This is also the officially recommended tool for uploading packages.
Install
twine:$ pip install twineBuild the package:
$ python setup.py clean sdistUpload:
$ twine upload dist/*The tool will ask you for the username and password.
twine also lets you provide the credentials in environment variables:
$ TWINE_USERNAME=me TWINE_PASSWORD=passwd twine upload dist/* or via keyring.
Answers 3
Create a file in home dir by touch ~/.pypirc similar look like: added pytest optionally
[distutils] index-servers = pypi pypitest [pypi] repository=https://pypi.python.org/pypi username=your_username password=your_password [pypitest] repository=https://testpypi.python.org/pypi username=your_username password=your_password Things to care about the following error
403: Invalid or non-existent authentication information
If there is a
%in your password just type it without escaping; e.g.Hello%123If there is a space character in your password just type it without quotes; e.g.
Hello 123
Register your package against PyPI's server
python setup.py register -r pypi Upload your package
python setup.py sdist upload -r pypi From official doc
First, you need a PyPI user account
0 comments:
Post a Comment