2014-02-17 30 views
15

我按照指南How to submit a package to PyPI提交了一個包。 它扔以下錯誤:如何解決在將包提交給PyPI時出現「PyPI-test not found in .pypic」的問題?

 

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

我的操作系統是ENV和

CentOS release 6.2 (Final)
蟒蛇ENV是
Python 2.6.6

是什麼原因以及如何解決?

+1

我相信關鍵點在於.pyirc文件應該放在哪裏。請參閱下面的答案。 – Overdrivr

回答

1

我將「PyPI」/「PyPItest」替換爲小寫字母:「pypi」/「pypi-test」。錯誤消失,但提示另一個錯誤:

Server response (403): You are not allowed to store 'mypackage' package information. 
13

確保您的.pypirc文件位於/ home目錄中。

+0

這給了我'python:無法打開文件'setup.py':[Errno 2]沒有這樣的文件或目錄' – Pithikos

0

我用pypitest而不是pypi-test。像魅力一樣工作。

我按照指示通過Peter Downs

3

當我得到這個錯誤,我改變了我的.pypirc文件:

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

,然後我跑:

python setup.py register 

,而不是:

python setup.py register -r pypitest 

這促使我輸入了我輸入的用戶名和密碼,併成功註冊了該用戶名和密碼。注意我正在關注Peter Downs' Guide

我意識到這不會上傳到pypitest,但我仍然設法使用此方法註冊我的模塊到pypi。

+0

我有類似的問題。在哪裏可以找到允許您上傳到testpypi的解決方案?我在Windows 7上。 –

+0

不幸的是,我無法,對不起。 – Einstein

+0

@Einstein:看看我的答案。你的命令有一個明確的問題,你輸入'-r pypitest',但你的回購標題是'test'。這是行不通的 – Overdrivr

1

你應該在這裏刪除評論,因爲的distutils沒有正確解析它們:

index-servers = 
     PyPI # the live PyPI 
     PyPI-test # test PyPI 

所以才:

index-servers = 
     PyPI 
     PyPI-test 

或者甚至最好不要使用大小寫混合和破折號的庫存名稱,正如Junchen所建議的那樣。儘管目前的版本應該可以工作。

15

一些陷阱,以避免爲了使這項工作:

.pyirc文件預計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> 

我的直覺告訴我不是定製的PyPI庫的名字,不知道它的工作原理,否則。

然後,當你運行命令,簡單的提供-r(庫)標記pypitest

python setup.py register -r pypitest 

這應該做的伎倆。

+1

它的工作原理。我的問題是我的'.pypirc'文件的位置。 –

+2

@ nu-everest python封裝用戶指南在這方面真的不太清楚,我甚至不確定它提到了文件應該放在哪裏。很高興你能解決你的問題。 – Overdrivr

相關問題