Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jan0sch opened this issue Nov 15, 2024 · 3 comments

Comments

@jan0sch
Copy link

jan0sch commented Nov 15, 2024

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):

  • OS: FreeBSD 14.1
  • Label Studio Version 1.14.0.post0
  • Python 3.11.10

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
Copy link
Author

jan0sch commented Nov 17, 2024

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
Copy link
Contributor

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:

  • start with a new virtual env + sqlite db
  • run pip list -v | grep 1.14.0 to find the path to your label studio package:
❯ pip list -v | grep 1.14.0
label-studio                   1.14.0.post0   /path/to/your/site-packages pip
  • run python /path/to/your/site-packages/label_studio/manage.py migrate and share the output? I think this should reveal exactly which migration isn't being properly applied.

Cheers,
Jo

@jan0sch
Copy link
Author

jan0sch commented Nov 20, 2024

Hi, thanks for the hint how to get more debug info. :-)

Here is the output of it:

Operations to perform:
  Apply all migrations: admin, auth, authtoken, contenttypes, core, data_export, data_import, data_manager, django_rq, io_storages, labels_manager, ml, ml_model_providers, ml_models, organizations, projects, sessions, tasks, users, webhooks
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0001_initial... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying users.0001_squashed_0009_auto_20210219_1237... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying authtoken.0001_initial... OK
  Applying authtoken.0002_auto_20160226_1747... OK
  Applying authtoken.0003_tokenproxy... OK
  Applying authtoken.0004_alter_tokenproxy_options... OK
  Applying organizations.0001_squashed_0008_auto_20201005_1552... OK
  Applying projects.0001_squashed_0065_auto_20210223_2014... OK
  Applying projects.0002_auto_20210304_1457...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/lib/python3.11/site-packages/label_studio/manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/labelstudio/server/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  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?

It seems that one migration fails. Mysteriously the same stuff is running fine under Linux, so it should run under BSD too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants