python - 无法在 https ://upload. pypi.org/legacy/中上传包

标签 python python-3.x

我已经查看了 SO 中已有的答案,但似乎对我没有任何帮助。

我正在按照python命令上传我的包(注意:我是新用户并且已经使用用户名和密码注册了帐户):

创建 setup.py:

from setuptools import setup

setup(
    name='',  # This is the name of your PyPI-package.
    version='0.1',  # Update the version number for new releases
    scripts=['']  # The name of your script, and also the command you'll be using for calling it
)

打包脚本:

python setup.py sdist

注册账号:

python setup.py register

这提示我下面的消息(我选择第二个,因为我是新用户):

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]:

上传包:

python setup.py sdist upload

尝试以下步骤后,我在上传时遇到错误:

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

最佳答案

经过反复试验,我找到了简单的解决方案。另外,@hoefling 的回答帮助我解决了这些问题。

https://pypi.org/ 中注册为用户并使用问题中提到的注册帐户命令。

现在,三个神奇的步骤将解决这个问题。

pip install twine

python setup.py sdist

# This will ask for you username and password
twine upload dist/*

编辑:

如果你想升级你的包,只需按照以下简单的步骤:

  1. 删除build , dist , 和 <package name>.egg-info根目录中的文件夹。
  2. 更改 setup.py 中的版本号文件。
  3. 再次创建分布。例如:python setup.py sdist bdist_wheel
  4. 再次上传分发。例如:twine upload dist/*

关于python - 无法在 https ://upload. pypi.org/legacy/中上传包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49787860/

相关文章:

python - 如何在 Conv2d 中使用复杂类型?

python - 对 python 类同时使用 __setattr__ 和描述符

python - 扩展 xgboost.XGBClassifier

python - Groupby 名称用所有列中的最大值替换值 pandas

python - 具有多个键和多个属性的 JSON 类

python - 我应该将我的 cython 文件放在 python 发行版中的什么位置?

python - 不存在的全局字典的替代方案

python - 没有名为 'PIL' 的模块

python - 如果 TCP 通信中丢失数据包,如何将客户端重新连接到服务器?

python - Pandas 的 EMA 与股票的 EMA 不匹配?