Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unidentified Image Error #14

@iagomachadocs

Description

@iagomachadocs

Hi Gilson!
Thank you for this great package.

I'm having an issue with the download_state function. During the download of the shapefiles, some captcha image raises the PIL.UnidentifiedImageError and breaks the flow.

Ubuntu 20.04.6 LTS
Python 3.11.4

Traceback (most recent call last):
  File "/(my_project_directory)/main.py", line 14, in <module>
    result = car.download_state(state='PE', folder='PE', debug=True, chunk_size=3072)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/iago/.cache/pypoetry/virtualenvs/sicar-test-3qQYT9fP-py3.11/lib/python3.11/site-packages/SICAR/sicar.py", line 449, in download_state
    return self.download_cities(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/iago/.cache/pypoetry/virtualenvs/sicar-test-3qQYT9fP-py3.11/lib/python3.11/site-packages/SICAR/sicar.py", line 412, in download_cities
    result[(city, code)] = self.download_city_code(
                           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/iago/.cache/pypoetry/virtualenvs/sicar-test-3qQYT9fP-py3.11/lib/python3.11/site-packages/SICAR/sicar.py", line 346, in download_city_code
    captcha = self._driver.get_captcha(self._download_captcha())
                                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/iago/.cache/pypoetry/virtualenvs/sicar-test-3qQYT9fP-py3.11/lib/python3.11/site-packages/SICAR/sicar.py", line 205, in _download_captcha
    return Image.open(io.BytesIO(response.content))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/iago/.cache/pypoetry/virtualenvs/sicar-test-3qQYT9fP-py3.11/lib/python3.11/site-packages/PIL/Image.py", line 3298, in open
    raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f82a81a3740>

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions