Skip to content

window platfrom raise ImportError #1079

@Wang-Jun-Chao

Description

@Wang-Jun-Chao

run below code raise import error

import os
import asyncio

from agentscope.message import Msg
from agentscope.memory import InMemoryMemory, Mem0LongTermMemory
from agentscope.agent import ReActAgent
from agentscope.embedding import DashScopeTextEmbedding
from agentscope.formatter import DashScopeChatFormatter
from agentscope.model import DashScopeChatModel
from agentscope.tool import Toolkit


# 创建 mem0 长期记忆实例
long_term_memory = Mem0LongTermMemory(
    agent_name="Friday",
    user_name="user_123",
    model=DashScopeChatModel(
        model_name="qwen-max-latest",
        api_key=os.environ.get("DASHSCOPE_API_KEY"),
        stream=False,
    ),
    embedding_model=DashScopeTextEmbedding(
        model_name="text-embedding-v2",
        api_key=os.environ.get("DASHSCOPE_API_KEY"),
    ),
    on_disk=False,
)

# 基本使用示例
async def basic_usage():
    """基本使用示例"""
    # 记录记忆
    await long_term_memory.record([Msg("user", "我喜欢住民宿", "user")])

    # 检索记忆
    results = await long_term_memory.retrieve(
        [Msg("user", "我的住宿偏好", "user")],
    )
    print(f"检索结果: {results}")


asyncio.run(basic_usage())

if __name__ == '__main__':
    pass

error

检索结果: 喜欢住民宿
Exception ignored in: <function QdrantClient.__del__ at 0x00000213D53CDEE0>
Traceback (most recent call last):
  File "G:\software\Python\Python312\Lib\site-packages\qdrant_client\qdrant_client.py", line 163, in __del__
  File "G:\software\Python\Python312\Lib\site-packages\qdrant_client\qdrant_client.py", line 172, in close
  File "G:\software\Python\Python312\Lib\site-packages\qdrant_client\local\qdrant_local.py", line 88, in close
  File "G:\software\Python\Python312\Lib\site-packages\portalocker\portalocker.py", line 339, in unlock
  File "G:\software\Python\Python312\Lib\site-packages\portalocker\portalocker.py", line 244, in unlock
ImportError: sys.meta_path is None, Python is likely shutting down
Exception ignored in: <function QdrantClient.__del__ at 0x00000213D53CDEE0>
Traceback (most recent call last):
  File "G:\software\Python\Python312\Lib\site-packages\qdrant_client\qdrant_client.py", line 163, in __del__
  File "G:\software\Python\Python312\Lib\site-packages\qdrant_client\qdrant_client.py", line 172, in close
  File "G:\software\Python\Python312\Lib\site-packages\qdrant_client\local\qdrant_local.py", line 88, in close
  File "G:\software\Python\Python312\Lib\site-packages\portalocker\portalocker.py", line 339, in unlock
  File "G:\software\Python\Python312\Lib\site-packages\portalocker\portalocker.py", line 244, in unlock
ImportError: sys.meta_path is None, Python is likely shutting down

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions