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
19.38k stars 2.41k forks source link

django.db.utils.OperationalError: no such column: "project" - should this be a string literal in single-quotes? #6664

Open jan0sch opened 3 days ago

jan0sch commented 3 days ago

Describe the bug

After the installation via pip install label-studio it crashes upon start with an error message.

To Reproduce Steps to reproduce the behavior:

  1. python -m venv label-studio
  2. cd label-studio
  3. source bin/activate
  4. pip install label-studio
  5. label-studio start --data-dir ~/data --no-browser

Expected behavior Label Studio should start and run.

Screenshots

=> Database and media directory: /home/labelstudio/.local/share/label-studio
=> Static URL is set to: /static/
=> Database and media directory: /home/labelstudio/data
=> Static URL is set to: /static/
Read environment variables from: /home/labelstudio/data/.env
get 'SECRET_KEY' casted as '<class 'str'>' with default ''
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /pypi/label-studio/json HTTP/1.1" 200 33344
Initializing database..
Traceback (most recent call last):
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/sqlite3/base.py", line 324, in execute
    return super().execute(query)
           ^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such column: "project" - should this be a string literal in single-quotes?

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/labelstudio/server/bin/label-studio", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/label_studio/server.py", line 297, in main
    _apply_database_migrations()
  File "/home/labelstudio/server/lib/python3.11/site-packages/label_studio/server.py", line 62, in _apply_database_migrations
    call_command('migrate', '--no-color', verbosity=0)
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/core/management/__init__.py", line 194, in call_command
    return command.execute(*args, **defaults)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/migrations/operations/models.py", line 659, in database_forwards
    alter_together(
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 554, in alter_unique_together
    self._delete_composed_index(
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 592, in _delete_composed_index
    constraint_names = self._constraint_names(
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 1772, in _constraint_names
    constraints = self.connection.introspection.get_constraints(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/sqlite3/introspection.py", line 312, in get_constraints
    table_schema = cursor.execute(
                   ^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/sentry_sdk/utils.py", line 1788, in runner
    return sentry_patched_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/sentry_sdk/integrations/django/__init__.py", line 653, in execute
    result = real_execute(self, sql, params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/db/backends/sqlite3/base.py", line 324, in execute
    return super().execute(query)
           ^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: no such column: "project" - should this be a string literal in single-quotes?
Sentry is attempting to send 2 pending events
Waiting up to 2 seconds
Press Ctrl-C to quit

Environment (please complete the following information):

Additional context

I looked around and the sqlite3 database is created and contains some tables:

% sqlite3 data/label_studio.sqlite3
SQLite version 3.46.1 2024-08-13 09:16:08
Enter ".help" for usage hints.
sqlite> .tables
auth_group                        htx_user_user_permissions
auth_group_permissions            organization
auth_permission                   organizations_organizationmember
authtoken_token                   project
django_admin_log                  projects_projectmember
django_content_type               projects_projectonboarding
django_migrations                 projects_projectonboardingsteps
htx_user                          projects_projectsummary
htx_user_groups                   projects_projecttemplate
sqlite>

I tried to install globally instead of in an virtual environment but the behaviour and error stays the same.

jan0sch commented 1 day ago

Doing the pip install way seems to work under Linux (tested with current Fedora). But the issue seems related to database migrations under FreeBSD/Python. If I copy the initial database (sqlite3 file) from the Linux install over to the FreeBSD one then Label Studio starts and runs without issues.

jombooth commented 9 hours ago

I don't think we explicitly claim FreeBSD support, but I don't see why it shouldn't work. Could you run these steps to help us understand which migration is broken under FreeBSD:

❯ pip list -v | grep 1.14.0
label-studio                   1.14.0.post0   /path/to/your/site-packages pip

Cheers, Jo