Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
128 views
in Technique[技术] by (71.8m points)

Program doesn't run from console, only IDLE - Python 3.6

Simple code to tell me the weather only runs in the IDLE but does not from CMP. However, if you type the program into CMP it works just fine, only if you call the program does it not work. The error seems to occur in the second line with requests.get().

import requests
page = requests.get('https://www.wunderground.com/weather/us/ca/san-carlos/94070')
if page:
r1 = page.text.find('class="module-link">')
r2 = page.text[r1+1:].find('class="module-link">')
r3 = page.text[r1+r2:].find('</a></div>')
m = page.text[r1+r2+21:r1+r2+r3]
m = m.replace(".  ", "
")
m = m.replace(". ", "
")
m = m.replace(".", "")
print(m)
else:
    print('Unsuccessful')

Error:

C:UsersmilesAppDataLocalProgramsPythonPython36-32>weather.py
Traceback (most recent call last):
  File "C:Usersmilesanaconda3libsite-packagesurllib3connectionpool.py", line 654, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "C:Usersmilesanaconda3libsite-packagesurllib3connectionpool.py", line 274, in _get_conn
    return conn or self._new_conn()
  File "C:Usersmilesanaconda3libsite-packagesurllib3connectionpool.py", line 964, in _new_conn
    "Can't connect to HTTPS URL because the SSL module is not available."
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 "C:Usersmilesanaconda3libsite-packages
equestsadapters.py", line 449, in send
    timeout=timeout
  File "C:Usersmilesanaconda3libsite-packagesurllib3connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "C:Usersmilesanaconda3libsite-packagesurllib3util
etry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.wunderground.com', port=443): Max retries exceeded with url: /weather/us/ca/san-carlos/94070 (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 "C:UsersmilesAppDataLocalProgramsPythonPython36-32weather.py", line 2, in <module>
    page = requests.get('https://www.wunderground.com/weather/us/ca/san-carlos/94070')
  File "C:Usersmilesanaconda3libsite-packages
equestsapi.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "C:Usersmilesanaconda3libsite-packages
equestsapi.py", line 60, in request
    return sessi

on.request(method=method, url=url, **kwargs)
  File "C:Usersmilesanaconda3libsite-packages
equestssessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:Usersmilesanaconda3libsite-packages
equestssessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "C:Usersmilesanaconda3libsite-packages
equestsadapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.wunderground.com', port=443): Max retries exceeded with url: /weather/us/ca/san-carlos/94070 (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))
question from:https://stackoverflow.com/questions/65924572/program-doesnt-run-from-console-only-idle-python-3-6

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...