18

I upload a package to PyPI, but I got some trouble after upload, so I delete it completely, and I tried to re-upload, but there are some error after upload again:

HTTP Error 400: This filename has previously been used, you should use a different version.

It seems PyPI can track the upload activity, I delete project and account and upload again, but I can see the previous record. Why? How can I solve the problem?

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
zeleven
  • 436
  • 1
  • 6
  • 21

4 Answers4

17

In short, you cannot reupload a distribution with the same name due to stability reasons. Here you can read more about this issue at https://github.com/pypa/packaging-problems/issues/74.

You need to change the distribution's file name, usually done by increasing the version number, and upload it again.

sinoroc
  • 18,409
  • 2
  • 39
  • 70
wolfsgang
  • 884
  • 6
  • 12
3

Yes you can reupload the package with same name.

I had faced similar issue what I did was increased the version number in setup.py and delete the folders generated by running python setup.py sdist i.e. dist and your_package_name-egg.info and again run the commands python setup.py sdist to make the package upload ready.

I think pypi tracks the repo from folder generated by sdist i.e. dist and your_package_name-egg.info so you have to delete it.

mrk
  • 8,059
  • 3
  • 56
  • 78
2

If you are running your local pypi server then you can use -o,--overwrite option which will allow overwriting existing package files.

pypi-server -p 8080  --overwrite  ~/packages &
Arun Pal
  • 687
  • 7
  • 28
0

I got the same error below:

HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
This filename has already been used, use a different version. See https://pypi.org/help/#file-name-reuse for more information.

When I tried to upload a package to PyPI with the command below:

twine upload dist/*

So, I changed version from "0.0.1" to "0.0.2" or name from "example_package_superkai" to "example_package_hyperkai" in pyproject.toml as shown below, then I removed dist folder:

# "pyproject.toml"

...
[project]
...
# version = "0.0.1"
version = "0.0.2"
...

Or:

# "pyproject.toml"

...
[project]
# name = "example_package_superkai"
name = "example_package_hyperkai"
...

Then, I ran the command below:

python -m build

Finally, I could upload a package to PyPI with the command below:

twine upload dist/*
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129