正在自學Ninad Sathaye - Learning Python Application Development (2016, Packt Publishing - ebooks Account)。有一章節是將自己的代碼上傳到testPyPI。
在自己的用戶目錄下新建一個空白文件命名爲.pypirc。在該文件中,我輸入了自己的用戶名和密碼,假定用戶名是abc,密碼是123。一開始我輸入的內容如下:
[distutils]
index-servers=
pypi
testpypi
[testpypi]
repository = https://test.pypi.org/legacy/
username= <abc>
password= <123>
在Anaconda的命令窗口中運行如下代碼:
twine upload --repository testpypi dist/*
此時報錯:
HTTPError: 403 Client Error: Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for details for url: https://test.pypi.org/legacy/
在網上搜索一番後,懷疑是我的用戶名和密碼輸入有誤,把用戶名和密碼中的<>去掉,問題得到解決。
[distutils]
index-servers=
pypi
testpypi
[testpypi]
repository = https://test.pypi.org/legacy/
username= abc
password= 123
參考資料: