【问题标题】:Can't upload package to PyPi无法将包上传到 PyPi
【发布时间】:2018-07-26 21:13:50
【问题描述】:

我一直在尝试将包上传到 PyPi。我每次都会收到这个错误。

Upload failed (403): Invalid or non-existent authentication information. 
error: Upload failed (403): Invalid or non-existent authentication information. 

我先google了一下,发现GitHub上有几个问题。我按照大家说的有效,没有骰子。

我制作了一个~/.pypirc 文件,内容如下,就像大家说的那样

[distutils]
index-servers =
pypi

[pypi]
username: shadeyg56
password: 

我确实填写了密码部分,但显然我不会分享。 然后我跑了

python setup.py sdist upload

在正确的目录中,它返回了这个

running sdist
running egg_info
writing shades_package.egg-info\PKG-INFO
writing dependency_links to shades_package.egg-info\dependency_links.txt
writing top-level names to shades_package.egg-info\top_level.txt
reading manifest file 'shades_package.egg-info\SOURCES.txt'
writing manifest file 'shades_package.egg-info\SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst,
README.txt

running check
creating shades_package-0.1
creating shades_package-0.1\shades_package
creating shades_package-0.1\shades_package.egg-info
copying files to shades_package-0.1...
copying setup.py -> shades_package-0.1
copying shades_package\__init__.py -> shades_package-0.1\shades_package
copying shades_package\test.py -> shades_package-0.1\shades_package
copying shades_package.egg-info\PKG-INFO -> shades_package-0.1\shades_package.eg
g-info
copying shades_package.egg-info\SOURCES.txt -> shades_package-0.1\shades_package
.egg-info
copying shades_package.egg-info\dependency_links.txt -> shades_package-0.1\shade
s_package.egg-info
copying shades_package.egg-info\not-zip-safe -> shades_package-0.1\shades_packag
e.egg-info
copying shades_package.egg-info\top_level.txt -> shades_package-0.1\shades_packa
ge.egg-info
Writing shades_package-0.1\setup.cfg
Creating tar archive
removing 'shades_package-0.1' (and everything under it)
running upload
Password:
Submitting dist\shades_package-0.1.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.

我似乎无法弄清楚它为什么这样做。如果有人知道请告诉我。谢谢:)

【问题讨论】:

标签: python python-3.x pypi


【解决方案1】:

python setup.py registerpython setup.py uploaddeprecated不要使用它们。

按照Python Packaging Guide中的说明进行操作:

  1. 如果您还没有,请在 PyPI 上创建一个帐户。
  2. 为您的包创建源代码分发和轮子:python setup.py sdist bdist_wheel
  3. 安装twine(或确保您拥有2.0或更高版本):pip install twine
  4. 检查您的分发文件是否有错误:twine check dist/*
  5. (可选)Upload to the PyPI test server first(注意:需要单独的用户注册):twine upload --repository-url https://test.pypi.org/legacy/ dist/*
  6. 上传到 PyPI:twine upload dist/*

【讨论】:

    【解决方案2】:

    也许仔细检查 .pypirc 文件是否实际上与 setup.py 位于同一目录中,因为在您的问题中您将其称为“~/.pypirc”。 '~/' 表示该文件位于您的主目录中,我认为这不是您想要的位置。

    猜你喜欢
    • 2017-12-25
    • 2018-01-30
    • 2020-05-03
    • 2018-10-10
    • 2014-11-27
    相关资源
    最近更新 更多