Safeguard
Developer Tools•

Why does PyPI say a filename has been previously used?

PyPI never lets a distribution filename be reused, even after delete. Why the upload error appears, what the three causes are, and how to release a fix.

Safeguard Security Team
3 min read

PyPI refuses an upload when the filename, which combines project name, version and distribution type, was used before. This holds even if the file was deleted or the project was removed and recreated. The fix is to bump the version and upload again. You cannot replace the old file.

What PyPI documents

The PyPI help page lists three reasons for the filename errors: the filename has been used and the file still exists, the filename has been used but the file no longer exists, or a file with the exact same content exists. PyPI does not allow a filename to be reused, even after a project has been deleted and recreated. A distribution filename is the combination of project name, version number and distribution type, which means a given distribution for a given release of a given project will always resolve to the same file.

Why it works this way

Pinned installs and hash checking depend on it. If a name and version could be swapped, a requirements file with hashes would break, or worse, an attacker who gained access could swap a file under a trusted version. Fixing the name to one file keeps "version 2.3.1" meaning one thing.

The three cases

CaseWhat happenedWhat to do
File existsYou are re-uploading the same filenameIncrease the version
File deleted earlierThe slot is spent anywayIncrease the version
Same content under another namePyPI rejects duplicates of contentChange the content, usually by bumping the version

Steps to recover from a bad upload

  1. Do not try to delete and re-upload. It will fail again.
  2. Fix the problem in the code or the build.
  3. Increase the version, for example from 2.3.1 to 2.3.2, or use a post or release candidate style version if that suits your scheme.
  4. Rebuild and upload both sdist and wheel for the new version.
  5. If the bad file was dangerous, tell users to avoid it and see whether the registry's yank option fits your case. See PyPI yanked releases and pinned installs.
  6. Rotate any secret that went into the bad build.

Prevent it

  • Build once in CI and upload that exact output. A second build attempt at a later step is how mismatches happen.
  • Use a test index for a dry run before the real upload.
  • Make the version bump part of the release checklist, ideally automated from a tag.
  • Check the built files before upload, for contents and secrets.

For the same property on other registries, read can you overwrite a published package version.

Safeguard's dependency scanning and SBOM generation work on the exact versions you release and consume, which is the identity PyPI makes permanent.

Quick check

Can I delete the file and upload it again?

No. PyPI does not allow a filename to be reused, even when the file no longer exists.

What is the quickest fix?

Increase the version number, rebuild, and upload the new files.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.