HumanSignal / label-studio

Label Studio is a multi-type data labeling and annotation tool with standardized output format
https://labelstud.io
Apache License 2.0
18.93k stars 2.36k forks source link

No longer be able to install `label-studio` in Python 3.13 #6506

Open nekomeowww opened 1 week ago

nekomeowww commented 1 week ago

Describe the bug

Python 3.13 is released at Oct 7, currently, we can no longer install label-studio in Python 3.13:

> which pip
/opt/homebrew/Caskroom/miniforge/base/envs/labelstudio-cgi-repro/bin/pip

> pip install label-studio
Collecting label-studio
  Downloading label_studio-1.13.1-py3-none-any.whl.metadata (14 kB)
# many other dependencies...
Collecting htmlmin==0.1.12 (from label-studio)
  Downloading htmlmin-0.1.12.tar.gz (19 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
          exec(compile('''
          ~~~~^^^^^^^^^^^^
          # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ...<31 lines>...
          exec(compile(setup_py_code, filename, "exec"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ''' % ('/private/var/folders/m0/k_38ftb53yg0mqbcrrjypr3m0000gn/T/pip-install-6ttnzd70/htmlmin_d451826247444646a2c06bbaea3ec118/setup.py',), "<pip-setuptools-caller>", "exec"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/m0/k_38ftb53yg0mqbcrrjypr3m0000gn/T/pip-install-6ttnzd70/htmlmin_d451826247444646a2c06bbaea3ec118/setup.py", line 4, in <module>
          from htmlmin import __version__
        File "/private/var/folders/m0/k_38ftb53yg0mqbcrrjypr3m0000gn/T/pip-install-6ttnzd70/htmlmin_d451826247444646a2c06bbaea3ec118/htmlmin/__init__.py", line 28, in <module>
          from .main import minify, Minifier
        File "/private/var/folders/m0/k_38ftb53yg0mqbcrrjypr3m0000gn/T/pip-install-6ttnzd70/htmlmin_d451826247444646a2c06bbaea3ec118/htmlmin/main.py", line 28, in <module>
          import cgi
      ModuleNotFoundError: No module named 'cgi'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

To Reproduce

  1. mamba create -n labelstudio-cgi-repro python=3.13 -y
  2. mamba activate labelstudio-cgi-repro
  3. pip install label-studio
  4. See error

Expected behavior

With the release note says (https://docs.python.org/3/whatsnew/3.13.html), due to the suggested PEP 594 – Removing dead batteries from the standard library:

The remaining 19 “dead batteries” (legacy stdlib modules) have been removed from the standard library: aifc, audioop, cgi, cgitb, chunk, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu and xdrlib.

Therefore all the dependencies that used the deprecated std libs will throw this error.

The htmlmin is used in label-studio, it seems the currect active module is htmlmin2 instead of htmlmin from test with 3.13 by Remi-Gau · Pull Request #32 · christiansandberg/pytest-reporter-html1 as well as mentioning at Deprecation Warning: 'cgi' is deprecated and slated for removal in Python 3.13 · Issue #66 · mankyd/htmlmin.

Not sure what is the best move, can I just replace the htmlmin wth htmlmin2? Many of other dependencies are not yet tested completely.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context

danielcuque commented 1 week ago

I have the same problem :/

heidi-humansignal commented 1 week ago

Hi there,

Thank you for reporting this issue. The error you're encountering occurs because Python 3.13 has removed several legacy standard library modules, including cgi, as per PEP 594 – Removing dead batteries from the standard library. One of our dependencies, htmlmin, relies on the cgi module, which leads to the installation failure you've observed. At this time, Label Studio does not officially support Python 3.13. We recommend using Python 3.10 or earlier versions, which are fully supported. Please consider installing Label Studio using Python 3.10:

# Create a virtual environment with Python 3.10mamba create -n labelstudio-env python=3.10 -ymamba activate labelstudio-envpip install label-studio

We are actively working on updating our dependencies to ensure compatibility with newer Python versions, including Python 3.13. We appreciate your patience and will notify our users once Label Studio supports Python 3.13.

Thanks,

Tyler Conlee Head of Support HumanSignal

Comment by Tyler Conlee Workflow Run

sailfish009 commented 6 days ago

hello. It's unofficial, but you can use label-studio in python 3.13 using the following method.

// CONDA_ENV_PATH : /home//anaconda3/envs//lib/python3.13/ // psycopg2 git version only works with python 3.13

$ conda activate <ENV_NAME>
$ sudo apt-get install libpq-dev
$ pip install legacy-cgi
$ pushd  CONDA_ENV_PATH
$ cp site-packages/cgi.py .
$ popd
$ pip install label-studio
$ pushd  CONDA_ENV_PATH
$ rm -rf site-packages/psycopg2*
$ popd
$ git clone https://github.com/psycopg/psycopg2
$ cd psycopg2
$ python setup.py build
$ python setup.py install
$ <RUN LABEL-STUDIO CMD>
jombooth commented 4 days ago

Hi folks, this was addressed in https://github.com/HumanSignal/label-studio/pull/6534 but we haven't published a release to pypi or brew yet, that will take another couple of weeks or so. If you'd like, you could clone the repo and build a label-studio wheel yourself (using poetry build).

Note also that Django 4.2 LTS which this build uses doesn't actually officially support Python 3.13 afaik, see https://docs.djangoproject.com/en/5.1/releases/4.2/#python-compatibility; however, with the fixes I made, there are no longer any issues with dependency conflicts or failing builds.

nekomeowww commented 4 days ago

We are actively working on updating our dependencies to ensure compatibility with newer Python versions, including Python 3.13. We appreciate your patience and will notify our users once Label Studio supports Python 3.13.

Thanks

Hi folks, this was addressed in https://github.com/HumanSignal/label-studio/pull/6534 but we haven't published a release to pypi or brew yet, that will take another couple of weeks or so. If you'd like, you could clone the repo and build a label-studio wheel yourself (using poetry build).

So quickly, awesome!