After pypi.python.org has been migrated to pypi.org, I got an error when trying to upload a package to PyPI using the command as usual:
python2.7 setup.py sdist upload
The error message is:
Upload failed (410): Gone (This API has been deprecated and removed from legacy PyPI in favor of using the APIs available in the new PyPI.org implementation of PyPI (located at https://pypi.org/). For more information about migrating your use of this API to PyPI.org, please see https://packaging.python.org/guides/migrating-to-pypi-org/#uploading. For more information about the sunsetting of this API, please see https://mail.python.org/pipermail/distutils-sig/2017-June/030766.html)
I looked into the solution mentioned in the message and then googled a little bit. Unfortunately, the solutions I found were not working, including updating my local ~/.pypirc file. Like this:
[distutils]
index-servers =
pypi
[pypi]
repository:https://pypi.python.org/pypi or repository:https://upload.pypi.org/legacy/
username:yourusername
password:yourpassword
I still got the same error message. What should I do?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Upgrade to the very latest pip and setuptools; install twine:
pip install -U pip setuptools twine
Edit ~/.pypirc and comment out or remove repository:
[pypi] #repository:https://pypi.python.org/pypi
Use twine to upload your module to pypi from within the folder containing the module source, setup.py, and other files:
python setup.py sdist twine upload dist/*
See https://packaging.python.org/guides/migrating-to-pypi-org/#uploading
Method 2
If you are looking for legacy solution, try updating your ~/.pypirc file to this
[distutils]
index-servers =
pypi
[pypi]
repository: https://upload.pypi.org/legacy/
username: username
password: password
And running
python setup.py sdist upload -r pypi
Not sure if it will work right away. Since I did multiple things in order to get it working such as
- Updating both python and python3 (I am still on 2.7.12 and 3.5.2 though)
- Installing
twineif your system does not have it yet - Updating
pip,setuptoolsandtwineper phd‘s suggestion - Also
pip3 install -U pip setuptools twinemight help
Method 3
I recommend using twine.
Just install it:
pip install twine
And simply do:
twine upload dist/*
Note: Do this from root of your project
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0