Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Server response (401): You must login to access this feature" when registering package on pypi

I am trying to register a package on pyPI. After creating a .pypirc that looks like

[distutils] # this tells distutils what package indexes you can push to
index-servers =
  pypi
  pypitest

[pypi]
repository: https://pypi.python.org/pypi
username: "amfarrell"
password: "I dont post my passphrase publicly"

[pypitest]
repository: https://testpypi.python.org/pypi
username: "amfarrell"
password: "I dont post my passphrase publicly"

I run python setup.py register -r pypitest and I get an error that ends in "Server response (401): You must login to access this feature". How do I login to pypi from the terminal?

I also get the error "Upload failed (401): You must be identified to edit package information" when I run python setup.py sdist upload.

like image 603
Andrew Farrell Avatar asked Nov 28 '15 04:11

Andrew Farrell


3 Answers

I had this problem, and the issue was that I had no account at the PyPI test server - they use a different user DB so you need to sign up there as well as the main server.

like image 65
benwad Avatar answered Nov 19 '22 00:11

benwad


The problem is the quote marks around the passphrase in ~/.pypirc. The easiest way to solve this is to simply mv ~/.pypirc ~/dot-pypirc and run python setup.py register.

like image 22
Andrew Farrell Avatar answered Nov 19 '22 00:11

Andrew Farrell


Judging by a few trials, Server response (401): You must login to access this feature indicates authentication failure. This happens when either:

  1. your credentials are incorrect.
  2. you haven't created an account at said index.
  3. you are using python 3 and have a % in your password - see here for solution

Quotes are treated as part of the password/username, so, as you've noted, you must remove them.

like image 1
Tim Diels Avatar answered Nov 19 '22 00:11

Tim Diels