调用SDK出错
xxx肖先森 发布于2021-05 浏览:624 回复:1
0
收藏
快速回复

代码如下图所示

client = AipImageClassify(APP_ID, API_KEY, SECRET_KEY)
""" 读取图片 """
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
image = get_file_content('1.jpg')
""" 调用通用物体识别 """
keyword = client.advancedGeneral(image)
# """ 如果有可选参数 """
# options = {}
# options["baike_num"] = 5
#
# """ 带参数调用通用物体识别 """
# client.advancedGeneral(image, options)
print(keyword)

报错内容如下图所示

Traceback (most recent call last):
File "F:/综合实践/aip-python-sdk-4.15.7/code.py", line 18, in
keyword = client.advancedGeneral(image)
File "F:\综合实践\aip-python-sdk-4.15.7\aip\imageclassify.py", line 84, in advancedGeneral
return self._request(self.__advancedGeneralUrl, data)
File "F:\综合实践\aip-python-sdk-4.15.7\aip\base.py", line 89, in _request
authObj = self._auth()
File "F:\综合实践\aip-python-sdk-4.15.7\aip\base.py", line 168, in _auth
), proxies=self._proxies).json()
File "E:\Anaconda\envs\torch\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "E:\Anaconda\envs\torch\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "E:\Anaconda\envs\torch\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "E:\Anaconda\envs\torch\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "E:\Anaconda\envs\torch\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "E:\Anaconda\envs\torch\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
self._prepare_proxy(conn)
File "E:\Anaconda\envs\torch\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
conn.connect()
File "E:\Anaconda\envs\torch\lib\site-packages\urllib3\connection.py", line 359, in connect
conn = self._connect_tls_proxy(hostname, conn)
File "E:\Anaconda\envs\torch\lib\site-packages\urllib3\connection.py", line 496, in _connect_tls_proxy
ssl_context.check_hostname = True
ValueError: check_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED

按照官网文档进行调用python sdk产生如下错误 请问一下该如何处理

收藏
点赞
0
个赞
共1条回复 最后由隐居天涯回复于2021-05
#2隐居天涯回复于2021-05

我也遇到了同样的问题在相似图片搜索接口上

0
TOP
切换版块