400 ERROR: Invalid URI when uploading new PyPI package (twine)

Viewed 4441

I followed the official documentation for uploading packages to PyPI, as well as the information provided in PyPI readme, but I get a HTTP 400 error each time:

$ twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/ 
Enter your username: bradaallen
Enter your password:
Uploading brad_nlp_helpers-0.1.1-py3-none-any.whl
HTTPError: 400 Client Error: home_page: Invalid URI for url: 
https://upload.pypi.org/legacy/

I am using a ~/.pypirc

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
username=bradaallen
password=[password]

[pypitest]
username=bradaallen
password=[password]

For packages, I am using twine version 1.9.1 (pkginfo: 1.4.1, requests: 2.12.4, setuptools: 27.2.0, requests-toolbelt: 0.8.0, tqdm: 4.14.0)

When I use python setup.py sdist bdist_wheel upload I get the same issue:

Submitting dist\brad_nlp_helpers-0.1.1.tar.gz to
https://upload.pypi.org/legacy/ Upload failed (400): home_page: Invalid URI
error: Upload failed (400): home_page: Invalid URI

I have not specified the repository, as that is recommendation that is given by the API when uploading. I am seeing a 404 error at the link that PyPI recommends and am not seeing an alternative site I should use!

This is my first package, and I am not seeing this error elsewhere on the internet. Any thoughts re: what's going on?

5 Answers

When you run $ twine upload dist/* it means you are redeploying all versions of the package available in project directory. Your error shows that previous version 0.0.1 already exists in your pypi.org account. It shouldn't be redeployed unless deleted from your pypi.org account.

Solution:

Always specify the version your latest wheel generated after modifying your package code by running

$ twine upload dist/<your-latest-whl-version>

check your setup.py file

put url =""

build again

check """ PKG-INFO inside the src//PKG-INFO

""" Home-page: if it is there go on deploy

thanks

When you use README.md file as long_description in the setup.py, some strings such as ".*" do not support in PyPI. So, there is a need to remove them and rebuild the WHL file and upload it again by twine.

Related