How to upload new versions of project to PyPI with twine?
Solution 1
PyPI does not allow for the reuse of distribution filenames (project name + version number + distribution type).
This ensures that a given distribution for a given release for a given project will always resolve to the same file, and cannot be surreptitiously changed one day by the projects maintainer or a malicious party (it can only be removed).
You will need to change the version number to one that you haven't previously uploaded to PyPI.
You didn't mention how you're uploading the distribution, but if you're using twine
, it's also possible you're attempting to re-upload a previously uploaded distribution. To resolve this, you can do:
$ twine upload --skip-existing dist/*
Solution 2
Can get that error for following reasons:
- Didn't change your version in
setup.py
- didn't remove your previous dist file
Solution:
- Change the version number in
setup.py
. - Run setup file again.
python setup.py bdist_wheel
. - Upload only that dist file or run twine (if using).
twine upload --skip-existing dist/*
As mentioned by @dustin, dist file of same name cannot be uploaded again.
Solution 3
You need to change the version number.
Solution 4
Make sure your dist directory is empty before running
python setup.py sdist
Solution 5
The error seems to stem from the command:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
reusing the previous package version.
To fix this, try this:
twine upload --skip-existing --repository-url https://test.pypi.org/legacy/
dist/*
![Basel Akasha](https://i.stack.imgur.com/9DjEB.jpg?s=256&g=1)
Basel Akasha
I am an experienced software developer who thinks differently and critically. My passion for technology and curiosity led me to learn programming at a young age. Over the few past years, I have been involved in several software projects and I developed the skills that make a professional software developer.
Updated on June 11, 2022Comments
-
Basel Akasha about 2 years
I've uploaded my Python package to PyPI. But now I made new version of my package and need to upload it. I tried to make same progress which I did when upload the package first time. but give me this error:
HTTPError: 400 Client Error: File already exists. See https://pypi.org/help/#file-name-reuse for url: https://upload.pypi.org/legacy
Now, how to upload new version without any error?!
-
Aviv Cohn over 5 yearsThanks, saved my life :)
-
Allan Karlson almost 4 yearsOh I see, that I need to remove old dist in my folder.... Then there is not such an error message.
-
Vincenzooo almost 3 yearsThis is the correct answer (as also in other answers). Updating version number doesn't help if you have previous version built in same directory as new, since twine tries to upload all the versions found in that (dist) folder.