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