如何在将包提交给PyPI时修复".pypic中找不到PyPI-test"的问题?

hup*_*xue 18 python pip python-2.6 easy-install pypi

我按照指南如何向PyPI提交包以提交一个包.它抛出了以下错误:


    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

我的.pypirc文件上下文是:


    [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}}

我的操作系统环境是

CentOS release 6.2 (Final)
Run Code Online (Sandbox Code Playgroud) 和python env是
Python 2.6.6
Run Code Online (Sandbox Code Playgroud).

是什么原因以及如何解决?

Ove*_*ivr 20

为了使这项工作避免一些陷阱:

.pypirc文件位于HOME目录中.这适用于Windows和Unix.

如果它不起作用,那是因为在HOME变量指示的路径中找不到.pypirc文件.

在Windows上,要了解您的路径:

  • 使用PowerShell(如果使用的是pew用于管理实例的virtualenv) echo $HOME.

  • 使用默认的Windows控制台echo %HOMEPATH%(是的,谈论"可移植性")

然后将.pypirc文件放在该路径上.

至于文件,不要忘记distutil部分,否则它将无法工作.你的文件应该是这样的:

[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>
Run Code Online (Sandbox Code Playgroud)

我的直觉告诉我不要自定义pypi存储库名称,不确定它是否有效.

然后,当您运行该命令时,simple提供-r(repository)标志pypitest

python setup.py register -r pypitest
Run Code Online (Sandbox Code Playgroud)

这应该可以解决问题.

  • @ nu-everest python打包用户指南真的不清楚,我甚至不确定它提到文件应该去哪里.很高兴你能解决你的问题. (2认同)

Jos*_*osh 13

确保您的.pypirc文件位于/ home目录中.


hup*_*xue 2

我将“PyPI”/“PyPItest”都替换为小写字母:“pypi”/“pypi-test”。错误消失了,但又提示另一个错误:

 Server response (403): You are not allowed to store 'mypackage' package information.
Run Code Online (Sandbox Code Playgroud)