Python安装DocTR OCR遭遇SSL证书链自签名错误求助
问题描述
我正尝试在Python环境中安装DocTR,严格遵循官方文档步骤操作,但执行命令:
pip install -r demo/tf-requirements.txt
时受阻,报错信息如下:
Obtaining python-doctr[tf] from git+https://github.com/mindee/doctr.git#egg=python-doctr[tf] (from -r demo/tf-requirements.txt (line 1))
Cloning https://github.com/mindee/doctr.git to c:\users\user\desktop\doctrtest\doctr\src\python-doctr
Running command git clone --filter=blob:none --quiet https://github.com/mindee/doctr.git 'C:\Users\user\Desktop\DocTRTest\doctr\src\python-doctr'
fatal: unable to access 'https://github.com/mindee/doctr.git/': SSL certificate problem: self signed certificate in certificate chain
error: subprocess-exited-with-error
× git clone --filter=blob:none --quiet https://github.com/mindee/doctr.git 'C:\Users\user\Desktop\DocTRTest\doctr\src\python-doctr' did not run successfully.
│ exit code: 128
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
我曾在配置文件中添加"http.proxyStrictSSL": false,还安装了VS Code的win-ca扩展,但均未解决问题。
解决方案
全局关闭Git SSL证书验证
打开命令提示符或PowerShell,执行以下命令:git config --global http.sslverify false此设置会让Git忽略SSL证书验证问题,直接完成仓库克隆。
手动克隆仓库后本地安装
如果不想全局禁用SSL验证,可按以下步骤操作:- 临时关闭单次克隆的SSL验证并拉取仓库:
git clone -c http.sslverify=false https://github.com/mindee/doctr.git - 进入克隆后的目录:
cd doctr - 安装TensorFlow版本的DocTR:
pip install .[tf]
- 临时关闭单次克隆的SSL验证并拉取仓库:
导入系统根证书到Git
若需保留SSL验证,可将系统根证书路径配置给Git:git config --global http.sslCAInfo "C:\Windows\System32\certificates\root\ca-bundle.crt"路径可根据自身系统证书位置调整,也可通过win-ca扩展导出证书后指定对应文件路径。
内容的提问来源于stack exchange,提问作者Agusms

