【报错解决】ERROR:albumentations.check_version:Error fetching version info

YOLOv8训练时报错ERROR:albumentations.check_version:Error fetching version info

原因:

根本原因在于 check_version.py 文件中设置的超时时长太短,加载像Github这样的网站较慢,

解决方法:

在ultralytics/yolo/v8/detect/train.py文件中添加代码如下

1.导入包

import warnings
import os

2.修改ultralytics/yolo/v8/detect/train.py中运行代码如下

if __name__ == '__main__':
    # 忽略更新,解决:ERROR:albumentations.check_version:Error fetching version info
    os.environ['NO_ALBUMENTATIONS_UPDATE'] = '1'
    # 忽略 UserWarning
    warnings.filterwarnings("ignore", category=UserWarning)
    train()

Traceback (most recent call last): File "D:\PythonProject\jjm\week13\selenium\01-基础使用.py", line 20, in <module> browse = webdriver.Chrome(service=Service('chromedriver.exe'),options=options) File "D:\PythonProject\jjm\.venv\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__ super().__init__( ~~~~~~~~~~~~~~~~^ browser_name=DesiredCapabilities.CHROME["browserName"], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<3 lines>... keep_alive=keep_alive, ^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "D:\PythonProject\jjm\.venv\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 67, in __init__ super().__init__(command_executor=executor, options=options) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\PythonProject\jjm\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 260, in __init__ self.start_session(capabilities) ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^ File "D:\PythonProject\jjm\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 357, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\PythonProject\jjm\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 448, in execute self.error_handler.check_response(response) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "D:\PythonProject\jjm\.venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 232, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 137 Current browser version is 136.0.7103.114 with binary path C:\Users\不知道\AppData\Local\Google\Chrome\Application\chrome.exe Stacktrace: GetHandleVerifier [0x0x7ff7752f9235+2853861] GetHandleVerifier [0x0x7ff775053af0+79008] (No symbol) [0x0x7ff774e19bda] (No symbol) [0x0x7ff774e5de0f] (No symbol) [0x0x7ff774e5ce5b] (No symbol) [0x0x7ff774e564bd] (No symbol) [0x0x7ff774e52726] (No symbol) [0x0x7ff774ea63be] (No symbol) [0x0x7ff774ea5ad0] (No symbol) [0x0x7ff774e98293] (No symbol) [0x0x7ff774e61061] (No symbol) [0x0x7ff774e61df3] GetHandleVerifier [0x0x7ff77532414d+3029757] GetHandleVerifier [0x0x7ff77531e56d+3006237] GetHandleVerifier [0x0x7ff77533d5f2+3133346] GetHandleVerifier [0x0x7ff77506d9be+185198] GetHandleVerifier [0x0x7ff775074f0f+215231] GetHandleVerifier [0x0x7ff77505c354+113924] GetHandleVerifier [0x0x7ff77505c509+114361] GetHandleVerifier [0x0x7ff775043238+11240] BaseThreadInitThunk [0x0x7ffd09b8259d+29] RtlUserThreadStart [0x0x7ffd0b44af58+40]
最新发布
05-29
### 解决Selenium中因ChromeDriver版本不匹配导致的SessionNotCreatedException问题 在使用 Selenium 时,如果遇到 `selenium.common.exceptions.SessionNotCreatedException: Message: session not created` 的错误,通常是因为 ChromeDriver 的版本与浏览器版本不匹配。以下是解决此问题的方法: #### 1. 确认浏览器和驱动版本 首先需要确认当前安装的 Google Chrome 浏览器版本,并下载与之匹配的 ChromeDriver 版本。例如,如果 Chrome 浏览器版本为 136,则需要下载对应的 ChromeDriver 版本[^1]。 ```python import subprocess def get_chrome_version(): try: # 获取 Windows 平台上的 Chrome 版本 result = subprocess.run(['reg', 'query', r'HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon', '/v', 'version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) if "ERROR" not in result.stdout: version_info = result.stdout.split()[-1] return version_info except Exception as e: print(f"Error occurred while fetching Chrome version: {e}") return None ``` 通过上述代码可以动态获取本地安装的 Chrome 版本[^3]。 #### 2. 自动化下载匹配的 ChromeDriver 为了简化手动操作,可以使用 Python 脚本自动下载与 Chrome 浏览器版本匹配的 ChromeDriver。以下是一个示例脚本: ```python import os import requests import zipfile from selenium import webdriver def download_chromedriver(version): url = f"https://chromedriver.storage.googleapis.com/{version}/chromedriver_win32.zip" response = requests.get(url) with open("chromedriver.zip", "wb") as file: file.write(response.content) with zipfile.ZipFile("chromedriver.zip", "r") as zip_ref: zip_ref.extractall() os.remove("chromedriver.zip") chrome_version = get_chrome_version() if chrome_version: major_version = chrome_version.split(".")[0] chromedriver_version_url = f"https://chromedriver.storage.googleapis.com/LATEST_RELEASE_{major_version}" latest_chromedriver_version = requests.get(chromedriver_version_url).text.strip() download_chromedriver(latest_chromedriver_version) # 配置 Selenium WebDriver chromium_driver_path = "./chromedriver" s = Service(chromium_driver_path) s.creation_flags = CREATE_NO_WINDOW # 屏蔽控制台输出 driver = webdriver.Chrome(service=s) ``` 这段代码会根据当前安装的 Chrome 版本,自动下载并解压对应的 ChromeDriver[^3]。 #### 3. 捕获特定 WebElement 的屏幕截图 如果需要捕获特定 WebElement 的屏幕截图,可以参考以下方法[^2]: ```python from PIL import Image from selenium.webdriver.common.action_chains import ActionChains element = driver.find_element("id", "element_id") location = element.location size = element.size png = driver.get_screenshot_as_png() image = Image.open(io.BytesIO(png)) left = location['x'] top = location['y'] right = location['x'] + size['width'] bottom = location['y'] + size['height'] image = image.crop((left, top, right, bottom)) image.save("element_screenshot.png") ``` #### 4. 处理证书验证错误 如果运行 Selenium 脚本时出现证书验证错误,可以通过设置忽略 SSL 证书验证来解决[^3]: ```python options = webdriver.ChromeOptions() options.add_argument("--ignore-certificate-errors") driver = webdriver.Chrome(service=s, options=options) ``` 这样可以避免因自签名证书或无效证书引发的错误。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值