5

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?

Toastrackenigma
  • 7,604
  • 4
  • 45
  • 55
Brad Allen
  • 115
  • 1
  • 2
  • 6
  • I just visited the page https://upload.pypi.org/legacy/ and got error 404 (not exists). What version of `twine` do you use? May be you need to create `.pypirc`?… – phd Jul 07 '17 at 10:05
  • 1
    Hi @phd - thanks for your comment. I've updated the version of twine and .pypirc data I used. I also noticed the website does not exist - it is the URL recommended by the PyPI API. I am not seeing this problem elsewhere, which makes me wonder if it is a recent issue with PyPI. Thoughts? – Brad Allen Jul 07 '17 at 21:22
  • No idea. I created `.pypirc` 15 years ago and have been happily using `python setup.py upload` ever after. :-))) – phd Jul 07 '17 at 21:29
  • @phd :) - I get the same issue with `python setup.py sdist bdist_wheel upload`. I just ran that code and got this error: `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` – Brad Allen Jul 07 '17 at 23:22
  • You don't have `https://upload.pypi.org/legacy/` in .pypirc, do you?! PS. I switched to twine a year ago, no problems so far. – phd Jul 07 '17 at 23:32
  • @phd: I don't! I updated my post to reflect the .pypirc I am using. I can add a line to the .pypirc stating `repository = www.correcturl.com`, but I don't know what that URL should be. Have you used twine in recent days? I'm curious if it is a global problem with the documentation or if it is something that is affecting me specifically. I appreciate your quick and consistent responses! – Brad Allen Jul 08 '17 at 01:21
  • I use https://pypi.python.org/pypi . No, I didn't use use twine for a few months. – phd Jul 08 '17 at 12:47

5 Answers5

2

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!

Brad Allen
  • 115
  • 1
  • 2
  • 6
0

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!

phd
  • 82,685
  • 13
  • 120
  • 165
  • Hi @phd - Thanks so much for continuing to help with this! :) When I run `pip install -U pip setuptools twine` on both my Mac and Win7 machines, I get this error: `OSError: [Errno 2] No such file or directory: '/Users/bradaallen/anaconda/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg'` I *do not* get this error if I upgrade the 3 packages separately - but I am also told that each package is "up-to-date" and I get the same errors as in my original post. Thoughts? – Brad Allen Jul 11 '17 at 01:00
  • Search `*.pth` files in `/Users/bradaallen/anaconda/lib/python2.7/site-packages/` and remove (comment out) mentioning of `setu‌​ptools-27.2.0-py2.7.‌​egg`. setu‌​ptools 27 is a bit old now. – phd Jul 11 '17 at 16:23
0

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>

0

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

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 26 '22 at 01:32
-3

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.

  • 1
    Your answer is a little unclear. What do you mean by *who file uploaded*? And might you be more specific about *some characters*? If you could [edit] your answer to clarify the English a little and include an example of a `README.md` that caused the problem, it would make this answer a lot more useful, thanks. – dbc Jun 24 '21 at 15:48