Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ModuleNotFoundError: No module named 'flags.state'; 'flags' is not a package

I’ve succesfully installed the flags package:

pip install flags                                                                                                                                                                                                       ─╯
Collecting flags
  Downloading flags-0.0.1.2.tar.gz (1.0 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: flags
  Building wheel for flags (pyproject.toml) ... done
  Created wheel for flags: filename=flags-0.0.1.2-py3-none-any.whl size=1698 sha256=9f7a6085b3e27960f9a56d8a3e2cb4781e1f6369fd572ab5610df42e745559ae
  Stored in directory: /Users/l028/Library/Caches/pip/wheels/1a/fc/32/fdc14bda566c3b37624cad853634811349fe105b21a829e7e5
Successfully built flags
Installing collected packages: flags
Successfully installed flags-0.0.1.2

However, when I run llmstack that required this dependency to flags, I keep getting this error:

llmstack                                                                                                                                                                                                                ─╯
/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/llmstack/apps/apps.py:47: RuntimeWarning: coroutine 'SyncToAsync.__call__' was never awaited
  sync_to_async(add_missing_app_types)()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
Traceback (most recent call last):
  File "/Users/l028/.pyenv/versions/llm_stack/bin/llmstack", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/llmstack/cli.py", line 308, in main
    run_django_command(["manage.py", "migrate", "--noinput"])
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/llmstack/cli.py", line 18, in run_django_command
    execute_from_command_line(command)
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/management/base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 100, in handle
    self.check(databases=[database])
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/management/base.py", line 486, in check
    all_issues = checks.run_checks(
                 ^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    return check_method()
           ^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/urls/resolvers.py", line 519, in check
    for pattern in self.url_patterns:
                   ^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/utils/functional.py", line 47, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/urls/resolvers.py", line 738, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
                       ^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/utils/functional.py", line 47, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/urls/resolvers.py", line 731, in urlconf_module
    return import_module(self.urlconf_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/llmstack/server/urls.py", line 7, in <module>
    path("", include("llmstack.apps.urls")),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/django/urls/conf.py", line 39, in include
    urlconf_module = import_module(urlconf_module)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/l028/.pyenv/versions/3.11.8/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/llmstack/apps/urls.py", line 3, in <module>
    from . import apis
  File "/Users/l028/.pyenv/versions/3.11.8/envs/llm_stack/lib/python3.11/site-packages/llmstack/apps/apis.py", line 15, in <module>
    from flags.state import flag_enabled
ModuleNotFoundError: No module named 'flags.state'; 'flags' is not a package

What seems to be the problem and how to fix it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

pip install flags installs https://pypi.org/project/flags/ which only provides module flags.py, not any packages, not submodules, so no flgas.state. You need a different package django-flags. So first uninstall flags and install django-flags:

pip uninstall -y flags
pip install django-flags

Report the problem at https://github.com/trypromptly/LLMStack/issues

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading