HLS tutorial - HTTPError: HTTP Error 403: Forbidden
Posted: Tue Apr 15, 2025 12:09 pm America/New_York
Hello, I'm following HLS tutorial notebook from here https://github.com/nasa/HLS-Data-Resources/blob/main/python/tutorials/HLS_Tutorial.ipynb. When trying to execute the cell from the point 3.2 I am getting a HTTPS 403 error, specifically from this code line:
image = io.imread(browse_urls[10])
I have properly login with earthaccess through .netrc file
Traceback:
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
Cell In[16], line 1
----> 1 image = io.imread(browse_urls[10]) # Load jpg browse image into memory
3 # Basic plot of the image
4 plt.figure(figsize=(10,10))
File ~/dev/HLS-Data-Resources/.venv/lib/python3.11/site-packages/skimage/io/_io.py:59, in imread(fname, as_gray, plugin, **plugin_args)
56 if fname.lower().endswith(('.tiff', '.tif')):
57 plugin = 'tifffile'
---> 59 with file_or_url_context(fname) as fname:
60 img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
62 if not hasattr(img, 'ndim'):
File ~/.pyenv/versions/3.11.9/lib/python3.11/contextlib.py:137, in _GeneratorContextManager.__enter__(self)
135 del self.args, self.kwds, self.func
136 try:
--> 137 return next(self.gen)
138 except StopIteration:
139 raise RuntimeError("generator didn't yield") from None
File ~/dev/HLS-Data-Resources/.venv/lib/python3.11/site-packages/skimage/io/util.py:27, in file_or_url_context(resource_name)
25 try:
26 with tempfile.NamedTemporaryFile(delete=False, suffix=ext) as f:
---> 27 with urllib.request.urlopen(resource_name) as u:
28 f.write(u.read())
29 # f must be closed before yielding
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:216, in urlopen(url, data, timeout, cafile, capath, cadefault, context)
214 else:
215 opener = _opener
--> 216 return opener.open(url, data, timeout)
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:525, in OpenerDirector.open(self, fullurl, data, timeout)
523 for processor in self.process_response.get(protocol, []):
524 meth = getattr(processor, meth_name)
--> 525 response = meth(req, response)
527 return response
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:634, in HTTPErrorProcessor.http_response(self, request, response)
631 # According to RFC 2616, "2xx" code indicates that the client's
632 # request was successfully received, understood, and accepted.
633 if not (200 <= code < 300):
--> 634 response = self.parent.error(
635 'http', request, response, code, msg, hdrs)
637 return response
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:563, in OpenerDirector.error(self, proto, *args)
561 if http_err:
562 args = (dict, 'default', 'http_error_default') + orig_args
--> 563 return self._call_chain(*args)
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
494 for handler in handlers:
495 func = getattr(handler, meth_name)
--> 496 result = func(*args)
497 if result is not None:
498 return result
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:643, in HTTPDefaultErrorHandler.http_error_default(self, req, fp, code, msg, hdrs)
642 def http_error_default(self, req, fp, code, msg, hdrs):
--> 643 raise HTTPError(req.full_url, code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
image = io.imread(browse_urls[10])
I have properly login with earthaccess through .netrc file
Traceback:
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
Cell In[16], line 1
----> 1 image = io.imread(browse_urls[10]) # Load jpg browse image into memory
3 # Basic plot of the image
4 plt.figure(figsize=(10,10))
File ~/dev/HLS-Data-Resources/.venv/lib/python3.11/site-packages/skimage/io/_io.py:59, in imread(fname, as_gray, plugin, **plugin_args)
56 if fname.lower().endswith(('.tiff', '.tif')):
57 plugin = 'tifffile'
---> 59 with file_or_url_context(fname) as fname:
60 img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
62 if not hasattr(img, 'ndim'):
File ~/.pyenv/versions/3.11.9/lib/python3.11/contextlib.py:137, in _GeneratorContextManager.__enter__(self)
135 del self.args, self.kwds, self.func
136 try:
--> 137 return next(self.gen)
138 except StopIteration:
139 raise RuntimeError("generator didn't yield") from None
File ~/dev/HLS-Data-Resources/.venv/lib/python3.11/site-packages/skimage/io/util.py:27, in file_or_url_context(resource_name)
25 try:
26 with tempfile.NamedTemporaryFile(delete=False, suffix=ext) as f:
---> 27 with urllib.request.urlopen(resource_name) as u:
28 f.write(u.read())
29 # f must be closed before yielding
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:216, in urlopen(url, data, timeout, cafile, capath, cadefault, context)
214 else:
215 opener = _opener
--> 216 return opener.open(url, data, timeout)
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:525, in OpenerDirector.open(self, fullurl, data, timeout)
523 for processor in self.process_response.get(protocol, []):
524 meth = getattr(processor, meth_name)
--> 525 response = meth(req, response)
527 return response
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:634, in HTTPErrorProcessor.http_response(self, request, response)
631 # According to RFC 2616, "2xx" code indicates that the client's
632 # request was successfully received, understood, and accepted.
633 if not (200 <= code < 300):
--> 634 response = self.parent.error(
635 'http', request, response, code, msg, hdrs)
637 return response
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:563, in OpenerDirector.error(self, proto, *args)
561 if http_err:
562 args = (dict, 'default', 'http_error_default') + orig_args
--> 563 return self._call_chain(*args)
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
494 for handler in handlers:
495 func = getattr(handler, meth_name)
--> 496 result = func(*args)
497 if result is not None:
498 return result
File ~/.pyenv/versions/3.11.9/lib/python3.11/urllib/request.py:643, in HTTPDefaultErrorHandler.http_error_default(self, req, fp, code, msg, hdrs)
642 def http_error_default(self, req, fp, code, msg, hdrs):
--> 643 raise HTTPError(req.full_url, code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden