首页 新闻 会员 周边 捐助

出现Traceback (most recent call last): File "...报错怎么办

0
悬赏园豆:10 [待解决问题]

运行代码:
import requests
import webbrowser
import time

api='https://api.github.com/repos/channelcat/sanic'
web_page='https://github.com/channelcat/sanic'
last_update='2020-03-26T01:35:00Z'
all_info=requests.get(api).json()
cur_update=all_info['updated_at']
print(cur_update)

while True:
if not last_update:
last_update=cur_update

if last_update<cur_update:
    webbrowser.open(web_page)
time.sleep(600)

                                            出现这种报错,怎么办?

D:\anaconda\python.exe D:/Desktop/Desktop/1.py
Traceback (most recent call last):
File "D:\anaconda\lib\site-packages\urllib3\connectionpool.py", line 588, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "D:\anaconda\lib\site-packages\urllib3\connectionpool.py", line 248, in _get_conn
return conn or self._new_conn()
File "D:\anaconda\lib\site-packages\urllib3\connectionpool.py", line 816, in _new_conn
raise SSLError("Can't connect to HTTPS URL because the SSL "
urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\anaconda\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "D:\anaconda\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "D:\anaconda\lib\site-packages\urllib3\util\retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/channelcat/sanic (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:/Desktop/Desktop/1.py", line 11, in <module>
all_info=requests.get(api).json()
File "D:\anaconda\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "D:\anaconda\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "D:\anaconda\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "D:\anaconda\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "D:\anaconda\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/channelcat/sanic (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

Process finished with exit code 1

竹枝词的主页 竹枝词 | 初学一级 | 园豆:192
提问于:2020-04-10 11:09
< >
分享
所有回答(2)
0
慌月初旧 | 园豆:202 (菜鸟二级) | 2020-04-10 11:21
0
#ssl异常而已加个参数就好了
import requests
import webbrowser
import time

api='https://api.github.com/repos/channelcat/sanic'
web_page='https://github.com/channelcat/sanic'
last_update='2020-03-26T01:35:00Z'
all_info=requests.get(api,verify=False).json()  #加verify=False即可
print(all_info)
cur_update=all_info['updated_at']
print(cur_update)



小小咸鱼YwY | 园豆:3312 (老鸟四级) | 2020-04-10 18:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册