LmeSzinc / StarRailCopilot

崩坏:星穹铁道脚本 | Honkai: Star Rail auto bot (简体中文/繁體中文/English/Español)
GNU General Public License v3.0
3.17k stars 158 forks source link

报错:cannot import name 'RootModel' from 'pydantic' #242

Open Diorite9248 opened 10 months ago

Diorite9248 commented 10 months ago

在提问之前...

描述你的问题

ImportError: cannot import name 'RootModel' from 'pydantic'

如何复现

  1. 打开 'SRC'
  2. 点击 '调度器-启动'
  3. 出现问题

预期行为

No response

相关 Logs

═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
                                                      DAILYQUEST                                                       
═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
2023-12-28 16:20:44.435 | INFO | [u2.Device] Device(atx_agent_url=http://127.0.0.1:11597)                              
2023-12-28 16:20:44.445 | INFO | [Device Orientation] 1 (HOME key on the right)                                        
2023-12-28 16:20:44.446 | INFO | [Screen_size] 1280x720                                                                
2023-12-28 16:20:44.447 | INFO | <<< SCRCPY SERVER START >>>                                                           
2023-12-28 16:20:44.451 | INFO | Create server stream                                                                  
2023-12-28 16:20:44.563 | INFO | b'[server] INFO: Device: Samsung SM-E5260 (Android 12)\n'                             
2023-12-28 16:20:44.565 | INFO | Create video socket                                                                   
2023-12-28 16:20:44.668 | INFO | Create control socket                                                                 
2023-12-28 16:20:44.673 | INFO | Fetch device info                                                                     
2023-12-28 16:20:44.674 | INFO | [Scrcpy Device] SM-E5260                                                              
2023-12-28 16:20:44.674 | INFO | [Scrcpy Resolution] (1280, 720)                                                       
2023-12-28 16:20:44.675 | INFO | Start video stream loop thread                                                        
2023-12-28 16:20:44.677 | INFO | Scrcpy server is up                                                                   
2023-12-28 16:20:44.847 | INFO | [Screen_size] 1280x720                                                                
2023-12-28 16:20:45.186 | ERROR | ImportError: cannot import name 'RootModel' from 'pydantic'                          
(C:\Users\HYY\AppData\Roaming\Python\Python310\site-packages\pydantic\__init__.cp310-win_amd64.pyd)                    
┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ D:\StarRailCopilot_0.5.3_fullcn\StarRailCopilot\module\alas.py:69 in run                                            │
│                                                                                                                     │
│    66 │   │   try:                                                                                                  │
│    67 │   │   │   self.device.screenshot()                                                                          │
│    68 │   │   │   self.device.screenshot_tracking.clear()                                                           │
│ >  69 │   │   │   self.__getattribute__(command)()                                                                  │
│    70 │   │   │   return True                                                                                       │
│    71 │   │   except TaskEnd:                                                                                       │
│    72 │   │   │   return True                                                                                       │
│                                                                                                                     │
│ ┌──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────┐ │
│ │ command = 'daily_quest'                                                                                         │ │
│ │       e = ImportError("cannot import name 'RootModel' from 'pydantic'                                           │ │
│ │           (C:\\Users\\HYY\\AppData\\Roaming\\Python\\Python310\\site-packages\\pydantic\\__init__.cp310-win_am… │ │
│ │    self = <src.StarRailCopilot object at 0x0000021AFCDCB4C0>                                                    │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                                                     │
│ D:\StarRailCopilot_0.5.3_fullcn\StarRailCopilot\src.py:34 in daily_quest                                            │
│                                                                                                                     │
│   31 │   │   WeeklyDungeon(config=self.config, device=self.device).run()                                            │
│   32 │                                                                                                              │
│   33 │   def daily_quest(self):                                                                                     │
│ > 34 │   │   from tasks.daily.daily_quest import DailyQuestUI                                                       │
│   35 │   │   DailyQuestUI(config=self.config, device=self.device).run()                                             │
│   36 │                                                                                                              │
│   37 │   def battle_pass(self):                                                                                     │
│                                                                                                                     │
│ ┌───────────────────────── locals ──────────────────────────┐                                                       │
│ │ self = <src.StarRailCopilot object at 0x0000021AFCDCB4C0> │                                                       │
│ └───────────────────────────────────────────────────────────┘                                                       │
│                                                                                                                     │
│ D:\StarRailCopilot_0.5.3_fullcn\StarRailCopilot\tasks\daily\daily_quest.py:25 in <module>                           │
│                                                                                                                     │
│    22 from tasks.dungeon.ui import DungeonUI                                                                        │
│    23 from tasks.item.consumable_usage import ConsumableUsageUI                                                     │
│    24 from tasks.item.relics import RelicsUI                                                                        │
│ >  25 from tasks.map.route.loader import RouteLoader                                                                │
│    26 from tasks.map.route.route import ROUTE_DAILY                                                                 │
│    27                                                                                                               │
│    28                                                                                                               │
│                                                                                                                     │
│ ┌──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────┐ │
│ │    ACTIVE_POINTS_1_CHECKED = ACTIVE_POINTS_1_CHECKED                                                            │ │
│ │     ACTIVE_POINTS_1_LOCKED = ACTIVE_POINTS_1_LOCKED                                                             │ │
│ │     ACTIVE_POINTS_1_UNLOCK = ACTIVE_POINTS_1_UNLOCK                                                             │ │
│ │    ACTIVE_POINTS_2_CHECKED = ACTIVE_POINTS_2_CHECKED                                                            │ │
│ │     ACTIVE_POINTS_2_LOCKED = ACTIVE_POINTS_2_LOCKED                                                             │ │
│ │     ACTIVE_POINTS_2_UNLOCK = ACTIVE_POINTS_2_UNLOCK                                                             │ │
│ │    ACTIVE_POINTS_3_CHECKED = ACTIVE_POINTS_3_CHECKED                                                            │ │
│ │     ACTIVE_POINTS_3_LOCKED = ACTIVE_POINTS_3_LOCKED                                                             │ │
│ │     ACTIVE_POINTS_3_UNLOCK = ACTIVE_POINTS_3_UNLOCK                                                             │ │
│ │    ACTIVE_POINTS_4_CHECKED = ACTIVE_POINTS_4_CHECKED                                                            │ │
│ │     ACTIVE_POINTS_4_LOCKED = ACTIVE_POINTS_4_LOCKED                                                             │ │
│ │     ACTIVE_POINTS_4_UNLOCK = ACTIVE_POINTS_4_UNLOCK                                                             │ │
│ │    ACTIVE_POINTS_5_CHECKED = ACTIVE_POINTS_5_CHECKED                                                            │ │
│ │     ACTIVE_POINTS_5_LOCKED = ACTIVE_POINTS_5_LOCKED                                                             │ │
│ │     ACTIVE_POINTS_5_UNLOCK = ACTIVE_POINTS_5_UNLOCK                                                             │ │
│ │                     Button = <class 'module.base.button.Button'>                                                │ │
│ │              ButtonWrapper = <class 'module.base.button.ButtonWrapper'>                                         │ │
│ │                   CameraUI = <class 'tasks.daily.camera.CameraUI'>                                              │ │
│ │          ConsumableUsageUI = <class 'tasks.item.consumable_usage.ConsumableUsageUI'>                            │ │
│ │                       crop = <function crop at 0x0000021AFFB155A0>                                              │ │
│ │                        cv2 = <module 'cv2' from                                                                 │ │
│ │                              'D:\\StarRailCopilot_0.5.3_fullcn\\StarRailCopilot\\toolkit\\lib\\site-packages\\… │ │
│ │           DAILY_QUEST_FULL = DAILY_QUEST_FULL                                                                   │ │
│ │           DAILY_QUEST_GOTO = DAILY_QUEST_GOTO                                                                   │ │
│ │     DAILY_QUEST_LEFT_START = DAILY_QUEST_LEFT_START                                                             │ │
│ │         DAILY_QUEST_REWARD = DAILY_QUEST_REWARD                                                                 │ │
│ │      DAILY_QUEST_RIGHT_END = DAILY_QUEST_RIGHT_END                                                              │ │
│ │       DAILY_TRAINING_CHECK = DAILY_TRAINING_CHECK                                                               │ │
│ │                 DailyQuest = <class 'tasks.daily.keywords.classes.DailyQuest'>                                  │ │
│ │            DailyQuestState = <class 'tasks.daily.keywords.classes.DailyQuestState'>                             │ │
│ │                  DungeonUI = <class 'tasks.dungeon.ui.DungeonUI'>                                               │ │
│ │  KEYWORD_BATTLE_PASS_QUEST = <module 'tasks.battle_pass.keywords.quest' from                                    │ │
│ │                              'D:\\StarRailCopilot_0.5.3_fullcn\\StarRailCopilot\\tasks\\battle_pass\\keywords\… │ │
│ │       KEYWORDS_DAILY_QUEST = <module 'tasks.daily.keywords.daily_quest' from                                    │ │
│ │                              'D:\\StarRailCopilot_0.5.3_fullcn\\StarRailCopilot\\tasks\\daily\\keywords\\daily… │ │
│ │ KEYWORDS_DAILY_QUEST_STATE = <module 'tasks.daily.keywords.daily_quest_state' from                              │ │
│ │                              'D:\\StarRailCopilot_0.5.3_fullcn\\StarRailCopilot\\tasks\\daily\\keywords\\daily… │ │
│ │       KEYWORDS_DUNGEON_TAB = <module 'tasks.dungeon.keywords.tab' from                                          │ │
│ │                              'D:\\StarRailCopilot_0.5.3_fullcn\\StarRailCopilot\\tasks\\dungeon\\keywords\\tab… │ │
│ │                     logger = <Logger alas (INFO)>                                                               │ │
│ │           MASK_DAILY_QUEST = MASK_DAILY_QUEST                                                                   │ │
│ │                         np = <module 'numpy' from                                                               │ │
│ │                              'C:\\Users\\HYY\\AppData\\Roaming\\Python\\Python310\\site-packages\\numpy\\__ini… │ │
│ │                        Ocr = <class 'module.ocr.ocr.Ocr'>                                                       │ │
│ │            OCR_DAILY_QUEST = OCR_DAILY_QUEST                                                                    │ │
│ │            OcrResultButton = <class 'module.ocr.ocr.OcrResultButton'>                                           │ │
│ │                   RelicsUI = <class 'tasks.item.relics.RelicsUI'>                                               │ │
│ │     split_and_pair_buttons = <function split_and_pair_buttons at 0x0000021AAC5C2830>                            │ │
│ │    SynthesizeConsumablesUI = <class 'tasks.daily.synthesize.SynthesizeConsumablesUI'>                           │ │
│ │       SynthesizeMaterialUI = <class 'tasks.daily.synthesize.SynthesizeMaterialUI'>                              │ │
│ │                      Timer = <class 'module.base.timer.Timer'>                                                  │ │
│ │             UseTechniqueUI = <class 'tasks.daily.use_technique.UseTechniqueUI'>                                 │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                                                     │
│ D:\StarRailCopilot_0.5.3_fullcn\StarRailCopilot\tasks\map\route\loader.py:9 in <module>                             │
│                                                                                                                     │
│     6 from module.logger import logger                                                                              │
│     7 from tasks.base.ui import UI                                                                                  │
│     8 from tasks.map.route.base import RouteBase                                                                    │
│ >   9 from tasks.map.route.model import RouteModel                                                                  │
│    10                                                                                                               │
│    11                                                                                                               │
│    12 def empty_function(*arg, **kwargs):                                                                           │
│                                                                                                                     │
│ ┌──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────┐ │
│ │   del_cached_property = <function del_cached_property at 0x0000021AFCD9F520>                                    │ │
│ │        GameStuckError = <class 'module.exception.GameStuckError'>                                               │ │
│ │ GameTooManyClickError = <class 'module.exception.GameTooManyClickError'>                                        │ │
│ │             importlib = <module 'importlib' from                                                                │ │
│ │                         'D:\\StarRailCopilot_0.5.3_fullcn\\StarRailCopilot\\toolkit\\lib\\importlib\\__init__.… │ │
│ │                logger = <Logger alas (INFO)>                                                                    │ │
│ │                    os = <module 'os' from                                                                       │ │
│ │                         'D:\\StarRailCopilot_0.5.3_fullcn\\StarRailCopilot\\toolkit\\lib\\os.py'>               │ │
│ │             RouteBase = <class 'tasks.map.route.base.RouteBase'>                                                │ │
│ │           ScriptError = <class 'module.exception.ScriptError'>                                                  │ │
│ │                    UI = <class 'tasks.base.ui.UI'>                                                              │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                                                     │
│ D:\StarRailCopilot_0.5.3_fullcn\StarRailCopilot\tasks\map\route\model.py:1 in <module>                              │
│                                                                                                                     │
│ >  1 from pydantic import BaseModel, RootModel                                                                      │
│    2                                                                                                                │
│    3                                                                                                                │
│    4 class RouteModel(BaseModel):                                                                                   │
│                                                                                                                     │
│ ┌─────────────────── locals ────────────────────┐                                                                   │
│ │ BaseModel = <class 'pydantic.main.BaseModel'> │                                                                   │
│ └───────────────────────────────────────────────┘                                                                   │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
ImportError: cannot import name 'RootModel' from 'pydantic'                                                            
(C:\Users\HYY\AppData\Roaming\Python\Python310\site-packages\pydantic\__init__.cp310-win_amd64.pyd)                    
2023-12-28 16:20:45.279 | WARNING | Saving error: ./log/error/1703751645279

截图

No response

还有别的吗?

No response

LmeSzinc commented 10 months ago

删除环境变量 PYTHONPATH 和 PYTHONHOME 以及指向 C:\Users\HYY\AppData\Roaming\Python\Python310 的环境变量