简体   繁体   中英

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

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?

Amazing. I also posted this as an Issue on Twine's GitHub page .

It turns out the URL in the setup.py file should correspond to where the code is being hosted (which makes sense). I had put my personal website as the URL and I guess the unit tests at Warehouse were rejecting me... it's now uploaded.

Thank you again @phd!

Just a few minutes ago tried to upload a package and got this problem. :-) To fix: upgrade pip , setuptools and twine to the very latest versions:

pip install -U pip setuptools twine

Remove or comment out repository from ~/.pypirc :

[distutils]
index-servers =
    pypi

[pypi]
#repository: 
username: …

twine upload now works!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM