我已成功安装
flags
软件包:
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
但是,当我运行需要此依赖关系的 llmstack 到
flags
时,我不断收到此错误:
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
问题是什么以及如何解决?
pip install flags
安装https://pypi.org/project/flags/,它只提供模块flags.py
,不提供任何包,不提供子模块,所以没有flgas.state
。您需要一个不同的包django-flags
。所以首先卸载flags
并安装django-flags
:
pip uninstall -y flags
pip install django-flags