Startup failure: the unpinned dashscope install now pulls 2.x, which cannot import on Python 3.10 (no tomllib, no tomli)

#49
by nootxlm - opened

This Space currently fails at startup. app.py line 5 installs dashscope unpinned at every boot:

os.system('pip install dashscope')

That now resolves to dashscope 2.x, and the import on line 7 dies on this Space's Python 3.10:

File "/usr/local/lib/python3.10/site-packages/dashscope/v2/_config.py", line 41, in <module>
    import tomllib
ModuleNotFoundError: No module named 'tomllib'

File "/home/user/app/app.py", line 7, in <module>
    import dashscope
  ...
File "/usr/local/lib/python3.10/site-packages/dashscope/v2/_config.py", line 43, in <module>
    import tomli as tomllib
ModuleNotFoundError: No module named 'tomli'

What is happening: tomllib only exists in Python 3.11+, and dashscope's fallback, tomli, is not part of dashscope's base install โ€” in dashscope 2.0.1's package metadata, tomli is declared only under the acli extras, so a plain pip install dashscope never installs it. The v2 config module imports it unconditionally at package import time, so the whole package is unimportable on Python 3.10.

Two small fixes, either one is enough:

  1. Add the missing module to the install line: pip install dashscope tomli.
  2. Or pin the 1.x line the app was written against: pip install "dashscope<2".

Pinning the install (either way) also removes the wider risk of an unpinned runtime install changing under the app on any future rebuild.

Check: after the change, import dashscope should succeed in the Space and startup should proceed past line 7.

Sign up or log in to comment