You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

上传PyPI时遭遇Error 405(Method Not Allowed)问题求助

Fixing PyPI Upload 405 Method Not Allowed Error

Hey there! That 405 error usually pops up because you're using an outdated upload method that PyPI no longer supports. Let's break down the solution step by step:

Common Cause: Deprecated setup.py upload Command

The old python setup.py upload command has been retired by PyPI—they've blocked this method entirely, which is why you're getting the "Method Not Allowed" response. You need to use twine instead, which is the recommended tool for secure package uploads.

Step-by-Step Fix

  1. Install Twine
    First, make sure you have twine installed on your system:

    pip install twine
    
  2. Build Your Package
    Before uploading, generate the distribution files (source tarball and wheel) using setup.py:

    python setup.py sdist bdist_wheel
    

    This will create a dist/ folder with your package files ready for upload.

  3. Upload with Twine
    Now use twine to upload your package to PyPI. You'll be prompted for your PyPI credentials (I recommend using an API token instead of your password for better security):

    twine upload dist/*
    

Additional Checks

  • If you have a ~/.pypirc configuration file, double-check that it's pointing to the correct PyPI repository with HTTPS:
    [pypi]
    repository = https://upload.pypi.org/legacy/
    username = __token__
    password = your-pypi-api-token-here
    
  • Ensure you're not accidentally targeting a test repository (like test.pypi.org) unless that's intentional—if you are, add the --repository testpypi flag to the twine command.

That should resolve the 405 error and get your spongebot package up on PyPI!

内容的提问来源于stack exchange,提问作者Javier Jiménez de la Jara

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:38:57