Skip to content

Installing version 1.7.0 on Windows #324

@PmasonFF

Description

@PmasonFF

The uploader in question stores the compress media file as a file_bytes io.BytesIO() file object, then attempts to add_location. This works fine with panoptes version 1.61. and 1.6.2 on windows (all be it with a libmagic WARNING). It now fails with an error:

Two cases:

Updating a Python 3.10 environment to version 1.7 on a windows machine throws this error:
Traceback (most recent call last):
File "C:\py_scripts\Scripts_Skunks\subject_uploader_tree_variable_resize_grouped_3revised_02-03-2023.py", line 203, in
subject.add_location(file_bytes)
File "C:\Users\User1\AppData\Local\Programs\Python\Python310\lib\site-packages\panoptes_client\subject.py", line 272, in add_location
media_type = magic.from_buffer(media_data, mime=True)
AttributeError: module 'magic' has no attribute 'from_buffer'

Workaround:
installing python-magic-bin after the update seems to fix it.

A clean install with Python 3.12 and installing panoptes-client 1.7.0 fails with another error:

Traceback (most recent call last):
File "C:\py_scripts _with_venv\Scripts_python_3.13\subject_uploader_tree_variable_resize_grouped_3revised_02-03-2023.py", line 203, in
subject.add_location(file_bytes)
File "C:\py_scripts _with_venv\Scripts_python_3.13\venv\Lib\site-packages\panoptes_client\subject.py", line 274, in add_location
media_type = mimetypes.guess_type(location)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User1\AppData\Local\Programs\Python\Python311\Lib\mimetypes.py", line 307, in guess_type
return _db.guess_type(url, strict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User1\AppData\Local\Programs\Python\Python311\Lib\mimetypes.py", line 122, in guess_type
url = os.fspath(url)
^^^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not BytesIO

Workaround:
Again fixing the libmagic with installing python-magic-bin resolves the issue.

So you have gone from having a libmagic warning with a standard install of panoptes client on a Windows machine to a full error situation - at least when the add-location refers to a BytesIO object - likely because the fall back mime type solution does not work with BytesIO????

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions