python “setup.py 上传”失败并显示“上传失败(401):您必须被识别才能编辑包信息”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1569315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"setup.py upload" is failing with "Upload failed (401): You must be identified to edit package information"
提问by dbr
When running..
跑的时候..
python setup.py sdist register upload
..I get the following output:
..我得到以下输出:
running register
We need to know who you are, so please choose either:
1. use your existing login,
2. register as a new user,
3. have the server generate a new password for you (and email it to you), or
4. quit
Your selection [default 1]: 1
Username: example
Password: ...
Registering mypackage to http://pypi.python.org/pypi
Server response (200): OK
I can store your PyPI login so future submissions will be faster.
(the login will be stored in /Users/dbr/.pypirc)
Save your login (y/N)?y
running upload
Submitting dist/mypackage-1.2.1.tar.gz to http://pypi.python.org/pypi
Upload failed (401): You must be identified to edit package information
It's prompting to save the login details, despite ~/.pypirc
already containing this. It then fails to upload files for a package I own, and have full write-access to.
它提示保存登录详细信息,尽管~/.pypirc
已经包含此信息。然后它无法为我拥有的包上传文件,并且具有完全写入权限。
回答by dbr
Just found this page, which solves the issue:
刚刚找到这个页面,它解决了这个问题:
I also noticed that while it was asking me to save my login information, and I hit Y everytime, it still asked me for the username and password. It turned out that it was saving the information incorrectly as follows:
[pypi] username:dcramer password:*******
Changing it out to this solved the problems:
[server-login] username:dcramer password:********
我还注意到,当它要求我保存我的登录信息时,我每次都按 Y,它仍然要求我输入用户名和密码。原来是它保存的信息不正确,如下:
[pypi] username:dcramer password:*******
把它改成这样解决了问题:
[server-login] username:dcramer password:********
The above content goes into the .pypirc
filein the user's home directory.
以上内容进入.pypirc
文件在用户的主目录。
Ugh.. I think this may be a good time to give distributea try..
呃..我认为这可能是尝试分发的好时机..
回答by dlink
None of the changes to ~/.pypirc listed here worked for me.
此处列出的对 ~/.pypirc 的任何更改都不适合我。
This worked for me, with no changes to ~/.pypirc. I added "-r https://www.python.org/pypi" to the command line:
这对我有用,对 ~/.pypirc 没有任何更改。我在命令行中添加了“-r https://www.python.org/pypi”:
python setup.py register sdist upload -r https://www.python.org/pypi
My ~/.pypirc looks like this
我的 ~/.pypirc 看起来像这样
[distutils]
index-servers: pypi
[pypi]
username: dlink
password: ******** (the real one)
回答by kongyue
I have the same problem, This is my solution.
我有同样的问题,这是我的解决方案。
The python version is 2.7.7, my windows version is Windows-7-6.1.7601-SP1.
python版本是2.7.7,我的windows版本是Windows-7-6.1.7601-SP1。
here is my .pypirc file
这是我的 .pypirc 文件
[distutils]
index-servers=pypi
[pypi]
repository = https://pypi.python.org/pypi
[server-login]
username = user
password = password
Notice:
注意:
In windows, A file is not allowed named as “.pypirc”,plz,refer to:
在windows中,不允许一个名为“.pypirc”的文件,请参考:
Rename files to empty filename in Windows
Then put you ".pypirc" file in the same folder with "setup.py"
然后将“.pypirc”文件与“setup.py”放在同一文件夹中
At last:
最后:
run :
跑 :
python setup.py sdist upload
or:
或者:
python setup.py sdist register upload
I hope this will be help,thank you!
我希望这会有所帮助,谢谢!
回答by Jasg
I have this problem and solved it by putting the file .pypirc under my home directory (~/), as the last past of the first comment suggests.
我遇到了这个问题,并通过将文件 .pypirc 放在我的主目录 (~/) 下解决了它,正如第一条评论的最后一段所暗示的那样。
I didn't have the need to modify the name of the section "pypi" of the file pypirc for "server-login", as suggested also in the first comment.
我不需要修改文件 pypirc 的“服务器登录”部分的“pypi”部分的名称,正如第一条评论中所建议的那样。
回答by Steven Almeroth
I changed [distutils]
to [pypirc]
as per the docsand this worked for me.
我换[distutils]
到[pypirc]
为每文档,这对我来说有效。
Here is my ~/.pypirc
file:
这是我的~/.pypirc
文件:
[pypirc]
index-servers =
pypi
pypitest
[pypi]
repository=https://pypi.python.org/pypi
[pypitest]
repository=https://testpypi.python.org/pypi
[server-login]
username:stav
password:****
回答by Mortoman
I had this problem, due to my own fault but hopefully this may help someone else who makes this same mistake.
由于我自己的过错,我遇到了这个问题,但希望这可以帮助犯同样错误的其他人。
I'm using python 3 on Linux Ubuntu, during registration I issued the setup command using sudo! The result was the .pypirc file in my home directory was owned by root and wasn't readable when trying to perform a module upload immediately after as a none privileged user.
我在 Linux Ubuntu 上使用 python 3,在注册期间我使用 sudo 发出了 setup 命令!结果是我的主目录中的 .pypirc 文件归 root 所有,并且在尝试以非特权用户身份立即执行模块上传时不可读。
By changing the ownership of the file to myself, the issue was resolved.
通过将文件的所有权更改为我自己,问题解决了。
回答by seanbehan
I ran into the same problem. I'm on a new OS X Sierra. Adding [server-login] entry to ~/.pypirc seemed to fix it
我遇到了同样的问题。我在新的 OS X Sierra 上。将 [server-login] 条目添加到 ~/.pypirc 似乎可以解决它