Reputation: 2234
I followed the guide How to submit a package to PyPI to submit one package. It throwed the error below:
Traceback (most recent call last): File "setup.py", line 27, in 'Programming Language :: Python', File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup dist.run_commands() File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands self.run_command(cmd) File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command cmd_obj.run() File "/usr/lib/python2.6/site-packages/setuptools/command/register.py", line 9, in run _register.run(self) File "/usr/lib64/python2.6/distutils/command/register.py", line 33, in run self._set_config() File "/usr/lib64/python2.6/distutils/command/register.py", line 84, in _set_config raise ValueError('%s not found in .pypirc' % self.repository) ValueError: PyPI-test not found in .pypirc
My .pypirc file context is:
[distutils] # this tells distutils what package indexes you can push to index-servers = PyPI # the live PyPI PyPI-test # test PyPI [PyPI] # authentication details for live PyPI repository: https://PyPI.python.org/PyPI username: {{username}} password: {{password}} [PyPI-test] # authentication details for test PyPI repository: https://testPyPI.python.org/PyPI username: {{username}}
My OS env is
CentOS release 6.2 (Final)
and python env is Python 2.6.6
.
What's the reason and how to fix it?
Upvotes: 21
Views: 7624
Reputation: 6576
Some pitfalls to avoid in order to make this work:
The .pypirc
file is expected inside the HOME
directory. This is true for Windows and Unix.
If it's not working, it's because the .pypirc file is not found at the path indicated by the HOME
variable.
On Windows, to know what your path is:
With PowerShell (if you are using pew
to manage virtualenv for instance), echo $HOME
.
With default Windows console, echo %HOMEPATH%
(yes, talk about "portability")
Then place the .pypirc file right at that path.
As for the file, don't forget the distutil part, otherwise it won't work. Your file should be EXACTLY like that:
[distutils]
index-servers =
pypi
pypitest
[pypitest]
repository = https://testpypi.python.org/pypi
username = <your user name goes here>
password = <your password goes here>
[pypi]
repository = https://pypi.python.org/pypi
username = <your user name goes here>
password = <your password goes here>
My intuition tells me to not customize the pypi repository name, not sure it works otherwise.
Then, when you run the command, simple provide the -r
(repository) flag with pypitest
python setup.py register -r pypitest
And that should do the trick.
Upvotes: 23
Reputation: 5613
You should remove the comments here since distutils doesn't parse them properly:
index-servers =
PyPI # the live PyPI
PyPI-test # test PyPI
So just:
index-servers =
PyPI
PyPI-test
Or maybe even better don't use mixed case and dashes for the repository names, as Junchen suggests. With the current version it should work, though.
Upvotes: 1
Reputation: 441
When I got this error, I changed my .pypirc file to:
[distutils]
index-servers =
pypi
test
[pypi]
repository: https://pypi.python.org/pypi
username: {{username}}
password: {{password}}
[test]
repository: https://testpypi.python.org/pypi
username: {{username}}
password: {{password}}
and then I ran:
python setup.py register
instead of:
python setup.py register -r pypitest
This prompted me for my username and password which I entered and it successfully registered. Note I was following Peter Downs' Guide
I realized this doesn't upload to pypitest, but I still managed to register my module to pypi using this method.
Upvotes: 4
Reputation: 1799
I used pypitest, rather than pypi-test. Works like charm.
I follow the instruction by Peter Downs
Upvotes: 0
Reputation: 2234
I replaced "PyPI"/"PyPItest" both to lowercase letters: "pypi"/"pypi-test". The error disappeared, but prompt another error:
Server response (403): You are not allowed to store 'mypackage' package information.
Upvotes: 2