Failed to load module #13097

Closed
opened 2026-02-21 19:10:34 -05:00 by yindo · 1 comment
Owner

Originally created by @edagarli on GitHub (Apr 17, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

FLASK_APP = app.py
FLASK_ENV = development
FLASK_DEBUG = 0
In folder /Users/edagarli_1/Desktop/code/newprojects/dify/api
/Users/edagarli_1/Library/Caches/pypoetry/virtualenvs/dify-api-YdOqIlwS-py3.12/bin/python -m flask run
2025-04-18 02:46:02,947.947 ERROR [MainThread] [module_import_helper.py:33] - Failed to load module core.model_runtime.model_providers.cohere.llm.llm from script file ''/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/cohere/llm/llm.py''
Traceback (most recent call last):
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/helper/module_import_helper.py", line 30, in import_module_from_source
spec.loader.exec_module(module)
File "", line 995, in exec_module
File "", line 488, in _call_with_frames_removed
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/cohere/llm/llm.py", line 7, in
from cohere import (
ImportError: cannot import name 'ChatStreamRequestToolResultsItem' from 'cohere' (/Users/edagarli_1/Library/Caches/pypoetry/virtualenvs/dify-api-YdOqIlwS-py3.12/lib/python3.12/site-packages/cohere/__init__.py). Did you mean: 'V2ChatStreamRequestDocumentsItem'?
Usage: python -m flask run [OPTIONS]
Try 'python -m flask run --help' for help.

Error: While importing 'app', an ImportError was raised:

Traceback (most recent call last):
File "/Users/edagarli_1/Library/Caches/pypoetry/virtualenvs/dify-api-YdOqIlwS-py3.12/lib/python3.12/site-packages/flask/cli.py", line 245, in locate_app
import(module_name)
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/app.py", line 37, in
app = create_app()
^^^^^^^^^^^^
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/app_factory.py", line 25, in create_app
initialize_extensions(app)
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/app_factory.py", line 87, in initialize_extensions
ext.init_app(app)
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/extensions/ext_import_modules.py", line 5, in init_app
from events import event_handlers # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/events/event_handlers/__init__.py", line 1, in
from .clean_when_dataset_deleted import handle
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/events/event_handlers/clean_when_dataset_deleted.py", line 2, in
from tasks.clean_dataset_task import clean_dataset_task
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/tasks/clean_dataset_task.py", line 7, in
from core.rag.index_processor.index_processor_factory import IndexProcessorFactory
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/rag/index_processor/index_processor_factory.py", line 4, in
from core.rag.index_processor.index_processor_base import BaseIndexProcessor
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/rag/index_processor/index_processor_base.py", line 7, in
from core.model_manager import ModelInstance
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_manager.py", line 7, in
from core.entities.provider_configuration import ProviderConfiguration, ProviderModelBundle
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/entities/provider_configuration.py", line 28, in
from core.model_runtime.model_providers import model_provider_factory
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/__init__.py", line 3, in
model_provider_factory = ModelProviderFactory()
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/model_provider_factory.py", line 32, in init
self.get_providers()
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/model_provider_factory.py", line 53, in get_providers
models = model_provider_instance.models(model_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/__base/model_provider.py", line 72, in models
model_instance = self.get_model_instance(model_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/__base/model_provider.py", line 104, in get_model_instance
mod = import_module_from_source(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/helper/module_import_helper.py", line 34, in import_module_from_source
raise e
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/helper/module_import_helper.py", line 30, in import_module_from_source
spec.loader.exec_module(module)
File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/cohere/llm/llm.py", line 7, in
from cohere import (
ImportError: cannot import name 'ChatStreamRequestToolResultsItem' from 'cohere' (/Users/edagarli_1/Library/Caches/pypoetry/virtualenvs/dify-api-YdOqIlwS-py3.12/lib/python3.12/site-packages/cohere/__init__.py). Did you mean: 'V2ChatStreamRequestDocumentsItem'?

Process finished with exit code 2

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @edagarli on GitHub (Apr 17, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.2 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce FLASK_APP = app.py FLASK_ENV = development FLASK_DEBUG = 0 In folder /Users/edagarli_1/Desktop/code/newprojects/dify/api /Users/edagarli_1/Library/Caches/pypoetry/virtualenvs/dify-api-YdOqIlwS-py3.12/bin/python -m flask run 2025-04-18 02:46:02,947.947 ERROR [MainThread] [module_import_helper.py:33] - Failed to load module core.model_runtime.model_providers.cohere.llm.llm from script file ''/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/cohere/llm/llm.py'' Traceback (most recent call last): File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/helper/module_import_helper.py", line 30, in import_module_from_source spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 995, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/cohere/llm/llm.py", line 7, in <module> from cohere import ( ImportError: cannot import name 'ChatStreamRequestToolResultsItem' from 'cohere' (/Users/edagarli_1/Library/Caches/pypoetry/virtualenvs/dify-api-YdOqIlwS-py3.12/lib/python3.12/site-packages/cohere/__init__.py). Did you mean: 'V2ChatStreamRequestDocumentsItem'? Usage: python -m flask run [OPTIONS] Try 'python -m flask run --help' for help. Error: While importing 'app', an ImportError was raised: Traceback (most recent call last): File "/Users/edagarli_1/Library/Caches/pypoetry/virtualenvs/dify-api-YdOqIlwS-py3.12/lib/python3.12/site-packages/flask/cli.py", line 245, in locate_app __import__(module_name) File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/app.py", line 37, in <module> app = create_app() ^^^^^^^^^^^^ File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/app_factory.py", line 25, in create_app initialize_extensions(app) File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/app_factory.py", line 87, in initialize_extensions ext.init_app(app) File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/extensions/ext_import_modules.py", line 5, in init_app from events import event_handlers # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/events/event_handlers/__init__.py", line 1, in <module> from .clean_when_dataset_deleted import handle File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/events/event_handlers/clean_when_dataset_deleted.py", line 2, in <module> from tasks.clean_dataset_task import clean_dataset_task File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/tasks/clean_dataset_task.py", line 7, in <module> from core.rag.index_processor.index_processor_factory import IndexProcessorFactory File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/rag/index_processor/index_processor_factory.py", line 4, in <module> from core.rag.index_processor.index_processor_base import BaseIndexProcessor File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/rag/index_processor/index_processor_base.py", line 7, in <module> from core.model_manager import ModelInstance File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_manager.py", line 7, in <module> from core.entities.provider_configuration import ProviderConfiguration, ProviderModelBundle File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/entities/provider_configuration.py", line 28, in <module> from core.model_runtime.model_providers import model_provider_factory File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/__init__.py", line 3, in <module> model_provider_factory = ModelProviderFactory() ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/model_provider_factory.py", line 32, in __init__ self.get_providers() File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/model_provider_factory.py", line 53, in get_providers models = model_provider_instance.models(model_type) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/__base/model_provider.py", line 72, in models model_instance = self.get_model_instance(model_type) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/__base/model_provider.py", line 104, in get_model_instance mod = import_module_from_source( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/helper/module_import_helper.py", line 34, in import_module_from_source raise e File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/helper/module_import_helper.py", line 30, in import_module_from_source spec.loader.exec_module(module) File "/Users/edagarli_1/Desktop/code/newprojects/dify/api/core/model_runtime/model_providers/cohere/llm/llm.py", line 7, in <module> from cohere import ( ImportError: cannot import name 'ChatStreamRequestToolResultsItem' from 'cohere' (/Users/edagarli_1/Library/Caches/pypoetry/virtualenvs/dify-api-YdOqIlwS-py3.12/lib/python3.12/site-packages/cohere/__init__.py). Did you mean: 'V2ChatStreamRequestDocumentsItem'? Process finished with exit code 2 ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-21 19:10:34 -05:00
Author
Owner

@crazywoola commented on GitHub (Apr 17, 2025):

We do not provide technical support for starting from the source. Thank you for your understanding. We assume you have the necessary expertise to set it up independently. If you require technical support, please obtain our business license by contacting us at business@dify.ai.

@crazywoola commented on GitHub (Apr 17, 2025): We do not provide technical support for starting from the source. Thank you for your understanding. We assume you have the necessary expertise to set it up independently. If you require technical support, please obtain our business license by contacting us at business@dify.ai.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13097