enthought / chaco

Chaco is a Python package for building interactive and custom 2-D plots.
http://docs.enthought.com/chaco/
Other
292 stars 99 forks source link

HTTP 404 error when running chaco/examples/demo/world_map.py #862

Closed homosapien-lcy closed 1 year ago

homosapien-lcy commented 1 year ago

Problem Description: HTTP 404 error when running the demo

Reproduction Steps: python chaco/examples/demo/world_map.py

Expected behavior: image gets downloaded and demo success

OS, Python version: [MacOS, Python3.8 or Python3.11]

dpinte commented 1 year ago

For the record, this is the image that the example try to load: "http://eoimages.gsfc.nasa.gov/ve//2433/land_shallow_topo_2048.jpg" (https://github.com/enthought/chaco/blob/main/examples/demo/world_map.py#L37)

dpinte commented 1 year ago

We could replace it with https://neo.gsfc.nasa.gov/servlet/RenderData?si=1845687&cs=rgb&format=JPEG&width=720&height=360

homosapien-lcy commented 1 year ago

We could replace it with https://neo.gsfc.nasa.gov/servlet/RenderData?si=1845687&cs=rgb&format=JPEG&width=720&height=360

After replacing with this link, a 403 error is caused.

How about this world map: https://upload.wikimedia.org/wikipedia/commons/9/91/Winkel_triple_projection_SW.jpg

dpinte commented 1 year ago

@homosapien-lcy

In [1]: import requests
In [2]: requests.get('https://neo.gsfc.nasa.gov/servlet/RenderData?si=1845687&cs=rgb&format=JPEG&width=720&height=360')
Out[2]: <Response [200]>
homosapien-lcy commented 1 year ago

https://neo.gsfc.nasa.gov/servlet/RenderData?si=1845687&cs=rgb&format=JPEG&width=720&height=360

Yeah, if you use requests it will work, but here is what I get if placing it in the world_map demo:

Downloading map image Traceback (most recent call last): File "examples/demo/world_map.py", line 132, in demo = WorldMapPlot() File "examples/demo/world_map.py", line 64, in init self._download_map_image() File "examples/demo/world_map.py", line 126, in _download_map_image request.urlretrieve(self.image_url, self.image_path) File "/Users/cyliu/.edm/envs/test_edm_py38/lib/python3.8/urllib/request.py", line 247, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "/Users/cyliu/.edm/envs/test_edm_py38/lib/python3.8/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/Users/cyliu/.edm/envs/test_edm_py38/lib/python3.8/urllib/request.py", line 531, in open response = meth(req, response) File "/Users/cyliu/.edm/envs/test_edm_py38/lib/python3.8/urllib/request.py", line 640, in http_response response = self.parent.error( File "/Users/cyliu/.edm/envs/test_edm_py38/lib/python3.8/urllib/request.py", line 569, in error return self._call_chain(args) File "/Users/cyliu/.edm/envs/test_edm_py38/lib/python3.8/urllib/request.py", line 502, in _call_chain result = func(args) File "/Users/cyliu/.edm/envs/test_edm_py38/lib/python3.8/urllib/request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden

image_url = Str( "https://neo.gsfc.nasa.gov/servlet/RenderData?si=1845687&cs=rgb&format=JPEG&width=720&height=360" )

homosapien-lcy commented 1 year ago

Fixed in PR #864