fohrloop / dash-uploader

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

AttributeError: module 'packaging.version' has no attribute 'LegacyVersion' #126

Closed CShaw-1 closed 1 year ago

CShaw-1 commented 1 year ago

Recieving the following error when trying to make a call-back using this package:

`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[18], line 60 16 return du.Upload( 17 id=id, 18 max_file_size=1800, # 1800 Mb 19 filetypes=['pdf'], 20 upload_id=uuid.uuid1(), # Unique session id 21 ) 24 app.layout = html.Div(children=[ 25 html.H1(children='Aug2023 - LLM Hackathon'), 26 (...) 53
54 ]) 56 @du.callback( 57 output=Output("callback-output", "children"), 58 id="dash-uploader", 59 ) ---> 60 def callback_on_completion(status: du.UploadStatus): 61 return html.Ul([html.Li(str(x)) for x in status.uploaded_files]) 65 if name == 'main':

File ~/anaconda3/lib/python3.10/site-packages/dash_uploader/callbacks.py:105, in callback..add_callback(function) 100 raise Exception( 101 "The du.configure_upload must be called before the @du.callback can be used! Please, configure the dash-uploader." 102 ) 104 kwargs = dict() --> 105 if dash_version_is_at_least("1.12"): 106 # See: https://github.com/plotly/dash/blob/dev/CHANGELOG.md and 107 # https://community.plotly.com/t/dash-v1-12-0-release-pattern-matching-callbacks-fixes-shape-drawing-new-datatable-conditional-formatting-options-prevent-initial-call-and-more/38867 108 # the prevent_initial_call option was added in Dash v.1.12 109 kwargs["prevent_initial_call"] = True 111 # Input: Change in the props will trigger callback. 112 # Whenever 'this.props.setProps' is called on the JS side, 113 # (dash specific special prop that is passed to every (...) 118 # 119 # See also: https://dash.plotly.com/basic-callbacks

File ~/anaconda3/lib/python3.10/site-packages/dash_uploader/utils.py:20, in dash_version_is_at_least(req_version) 12 def dash_version_is_at_least(req_version="1.12"): 13 """Check that the used version of dash is greater or equal 14 to some version req_version. 15 (...) 18 This is a private method, and should not be exposed to users. 19 """ ---> 20 if isinstance(dash_version, version.LegacyVersion): 21 return False 22 return dash_version >= version.parse(req_version)`

CShaw-1 commented 1 year ago

For anyone that has the same issue, run packaging version 21.3 and it fixes the issue.