fohrloop / dash-uploader

The alternative upload component for python Dash applications.
MIT License
141 stars 29 forks source link

Multiple issues with Linux-Python3.6 and Windows-Python3.7 #107

Open chuhoaianh opened 1 year ago

chuhoaianh commented 1 year ago

First of all, thank you for making this wonderful package.

I got 2 problems when running on 2 environments: Script:

The problems:

  1. ImportError: cannot import name 'final' from 'typing'
Traceback (most recent call last):
  File "C:\Users\user123\eclipse-workspace\For fun - Python\test7.py", line 3, in <module>
    import dash_uploader as du
  File "C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\site-packages\dash_uploader\__init__.py", line 7, in <module>
    from dash_uploader.configure_upload import configure_upload
  File "C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\site-packages\dash_uploader\configure_upload.py", line 5, in <module>
    from dash_uploader.httprequesthandler import HttpRequestHandler
  File "C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\site-packages\dash_uploader\httprequesthandler.py", line 11, in <module>
    from dash_uploader.utils import retry
  File "C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\site-packages\dash_uploader\utils.py", line 2, in <module>
    from typing import final
ImportError: cannot import name 'final' from 'typing' (C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\typing.py)

This can be fixed by: a. Commenting out from typing import final from utils.py (not sure whats the side effects by doing this) b. Change from typing import final -> from typing_extensions import final (for python 3.7 and below) For this problem, you might need to change the requirement might be python 3.8+ (I think python3.8 typing has final, though I havent checked), not python3.6+.

  1. pathlib.Path obj has no attribute 'write'

Linux: AttributeError: 'PosixPath' object has no attribute 'write' Windows: AttributeError: 'WindowsPath' object has no attribute 'write'

Error message in Windows

Traceback (most recent call last):
  File "C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\site-packages\dash_uploader\httprequesthandler.py", line 85, in post
    return self._post()
  File "C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\site-packages\dash_uploader\httprequesthandler.py", line 110, in _post
    r.chunk_data.save(chunk_file)
  File "C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\site-packages\werkzeug\datastructures.py", line 2803, in save
    copyfileobj(self.stream, dst, buffer_size)
  File "C:\Users\user123\AppData\Local\Programs\Python\Python37\lib\shutil.py", line 82, in copyfileobj
    fdst.write(buf)
AttributeError: 'WindowsPath' object has no attribute 'write'

To make this works, I have to edit: r.chunk_data.save(chunk_file) -> r.chunk_data.save(str(chunk_file)) in _post() ("httprequesthandler.py"). After this, files are uploaded normally.

Am I missing anything to make this work without editing the files?