IrisRainbowNeko / genshin_auto_fish

基于深度强化学习的原神自动钓鱼AI
4.78k stars 716 forks source link

这个问题怎么解决pywintypes.error: (1400, 'GetWindowRect', '无效的窗口句柄。') #243

Open 225ceV opened 2 years ago

225ceV commented 2 years ago

用预训练的三个权重文件运行以下语句时出错 python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device cpu conda环境python3.7 错误如下: PS C:\DATA\Project\genshin_auto_fish> python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device cpu Traceback (most recent call last): File "fishing.py", line 18, in from fisher.environment import File "C:\DATA\Project\genshin_auto_fish\fisher\environment.py", line 4, in from utils import File "C:\DATA\Project\genshin_auto_fish\utils__init__.py", line 2, in from .utils import * File "C:\DATA\Project\genshin_auto_fish\utils\utils.py", line 30, in gvars.genshin_window_rect = win32gui.GetWindowRect(hwnd) pywintypes.error: (1400, 'GetWindowRect', '无效的窗口句柄。')

另外在生成代码时有警告: PS C:\DATA\Project\genshin_auto_fish> python setup.py develop running develop running egg_info creating yolox.egg-info writing yolox.egg-info\PKG-INFO writing dependency_links to yolox.egg-info\dependency_links.txt writing top-level names to yolox.egg-info\top_level.txt writing manifest file 'yolox.egg-info\SOURCES.txt' C:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\utils\cpp_extension.py:369: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Fa lling back to using the slow distutils backend. warnings.warn(msg.format('we could not find ninja.')) reading manifest file 'yolox.egg-info\SOURCES.txt' writing manifest file 'yolox.egg-info\SOURCES.txt' running build_ext C:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\utils\cpp_extension.py:304: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。 warnings.warn(f'Error checking compiler version for {compiler}: {error}') building 'yolox._C' extension creating build creating build\temp.win-amd64-3.7 creating build\temp.win-amd64-3.7\Release creating build\temp.win-amd64-3.7\Release\DATA creating build\temp.win-amd64-3.7\Release\DATA\Project creating build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish creating build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox creating build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layers creating build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layers\csrc creating build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layers\csrc\cocoeval C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\DATA\Project\genshin_auto_fish\yol ox\layers\csrc -IC:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\include -IC:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Us ers\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\include\TH -IC:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\include\THC -IC:\Users\jinji\anaconda3\envs\ysfish\includ e -IC:\Users\jinji\anaconda3\envs\ysfish\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kit s\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinr t" /EHsc /TpC:\DATA\Project\genshin_auto_fish\yolox\layers\csrc\vision.cpp /Fobuild\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layers\csrc\vision.obj /MD /wd4819 /wd4 251 /wd4244 /wd4267 /wd4275 /wd4018 /wd4190 /EHsc -O3 -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 cl: 命令行 warning D9002 :忽略未知选项“-O3” vision.cpp C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\DATA\Project\genshin_auto_fish\yol ox\layers\csrc -IC:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\include -IC:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Us ers\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\include\TH -IC:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\include\THC -IC:\Users\jinji\anaconda3\envs\ysfish\includ e -IC:\Users\jinji\anaconda3\envs\ysfish\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kit s\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinr t" /EHsc /TpC:\DATA\Project\genshin_auto_fish\yolox\layers\csrc\cocoeval\cocoeval.cpp /Fobuild\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layers\csrc\cocoeval\cocoeva l.obj /MD /wd4819 /wd4251 /wd4244 /wd4267 /wd4275 /wd4018 /wd4190 /EHsc -O3 -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 cl: 命令行 warning D9002 :忽略未知选项“-O3” cocoeval.cpp creating C:\DATA\Project\genshin_auto_fish\build\lib.win-amd64-3.7 creating C:\DATA\Project\genshin_auto_fish\build\lib.win-amd64-3.7\yolox C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO / LIBPATH:C:\Users\jinji\anaconda3\envs\ysfish\lib\site-packages\torch\lib /LIBPATH:C:\Users\jinji\anaconda3\envs\ysfish\libs /LIBPATH:C:\Users\jinji\anaconda3\envs\ysfish\PCbuild\amd64 "/L IBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C :\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" c10.lib torch.lib torch_cpu.lib torch_python.lib /EXPORT:PyInit__C build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layers\csrc\vision.obj build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layer s\csrc\cocoeval\cocoeval.obj /OUT:build\lib.win-amd64-3.7\yolox_C.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layers\csrc_C.cp37-win _amd64.lib 正在创建库 build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish\yolox\layers\csrc_C.cp37-win_amd64.lib 和对象 build\temp.win-amd64-3.7\Release\DATA\Project\genshin_auto_fish \yolox\layers\csrc_C.cp37-win_amd64.exp 正在生成代码 已完成代码的生成 copying build\lib.win-amd64-3.7\yolox_C.cp37-win_amd64.pyd -> yolox Creating c:\users\jinji\anaconda3\envs\ysfish\lib\site-packages\yolox.egg-link (link to .) Removing yolox 0.1.0 from easy-install.pth file Adding yolox 0.1.0 to easy-install.pth file

Installed c:\data\project\genshin_auto_fish Processing dependencies for yolox==0.1.0 Finished processing dependencies for yolox==0.1.0

这是为什么呢?

IrisRainbowNeko commented 2 years ago

先打开原神再运行程序试试,程序运行需要检测原神窗口