0

I get the following error:

urllib.error.HTTPError: HTTP Error 403: Forbidden

When running this:

class FastText(Vectors):

    url_base = 'https://s3-us-west-1.amazonaws.com/fasttext-vectors/wiki.{}.vec'

    def __init__(self, language="en", **kwargs):
        url = self.url_base.format(language)
        name = os.path.basename(url)
        super(FastText, self).__init__(name, url=url, **kwargs)

How can I fix it?

Changing the url and that did not work

1 Answer 1

0

An HTTP 403 "Forbidden" error means that the server to which you've sent your request is refusing to let you access that URL, perhaps because it's not open to the public, or requires extra authentication.

If I try the URL https://s3-us-west-1.amazonaws.com/fasttext-vectors/wiki.en.vec from a web-browser, I get the same error. So this isn't really an issue with your code, or python, or pytorch, or fasttext. You've just got an improper expectation that the given URL will return what you wnat it to.

What reference, or entity, made you think https://s3-us-west-1.amazonaws.com/fasttext-vectors/wiki.en.vec would give you what you need? You may need to follow-up with whoever recommended that URL, and let them know their recommendation does not work, or find an alternate source.

Only if an URL works for you in your browser should you expect it will also work in your code, with no extra authentication steps. And, it still might break for other reasons, like the system where your code is running having a disfavored network IP-address – so before supplying such an URL to configure a custom subclass of Vectors, you might run some code from that same system to verify the URL loads at all.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer! The code I am trying to run is from the authors of a paper from 2019. The url was already there.
You're welcome! If the paper authors maintain an up-to-date guide beyond the original paper (which is rare), they could be advised to supply a new URL, or you'll just want to find an URL with the same vectors, or vectors of similar value for your project. And you may want to find the vectors once, saving them locally – then adapt the code to reuse that known-good local copy, rather than re-fetching from a remote URL repeatedly (which could break whenver that URL goes bad). Some of the offerings at <fasttext.cc/docs/en/english-vectors.html> might be applicable. Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.