I tried connecting to opensearch using python client but getting SSL Error.
OpenSearch Version: 2.0.1
Python Version:3.6
public IP of the opensearch host: 10.83.5.67
Here is the python code for connecting the client to opensearch:
from opensearchpy import *
host = '10.83.5.67'
port = 9200
auth = ('admin', 'admin') # For testing only. Don't store credentials in code.
ca_certs_path = '/etc/opensearch/cert.pem' # Provide a CA bundle if you use intermediate CAs with your root CA.
# Create the client with SSL/TLS enabled, but hostname verification disabled.
client = OpenSearch(
hosts = [{'host': host, 'port': port}],
http_compress = True, # enables gzip compression for request bodies
http_auth = auth,
use_ssl = True,
verify_certs = True,
ssl_assert_hostname = False,
ssl_show_warn = False,
ca_certs = ca_certs_path
)
The certificates used in opensearch.yml file are:
plugins.security.ssl.transport.pemcert_filepath: /etc/opensearch/cert.pem
plugins.security.ssl.transport.pemkey_filepath: /etc/opensearch/privkey.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: /etc/opensearch/fullchain.pem
plugins.security.ssl.http.pemcert_filepath: /etc/opensearch/cert.pem
plugins.security.ssl.http.pemkey_filepath: /etc/opensearch/privkey.pem
plugins.security.ssl.http.pemtrustedcas_filepath: /etc/opensearch/fullchain.pem
This is the error I am getting:
[root#ip-10-92-3-240 pyscripts]# python3 ospy4.py
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 358, in connect
ssl_context=context)
File "/usr/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 367, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/lib64/python3.6/ssl.py", line 365, in wrap_socket
_context=self, _session=session)
File "/usr/lib64/python3.6/ssl.py", line 776, in __init__
self.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 1036, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 648, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/opensearchpy/connection/http_urllib3.py", line 250, in perform_request
method, url, body, retries=Retry(False), headers=request_headers, **kw
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 344, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3.6/site-packages/urllib3/packages/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 358, in connect
ssl_context=context)
File "/usr/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 367, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/lib64/python3.6/ssl.py", line 365, in wrap_socket
_context=self, _session=session)
File "/usr/lib64/python3.6/ssl.py", line 776, in __init__
self.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 1036, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib64/python3.6/ssl.py", line 648, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ospy4.py", line 31, in <module>
response = client.indices.create(index_name, body=index_body)
File "/usr/local/lib/python3.6/site-packages/opensearchpy/client/utils.py", line 177, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
File "/usr/local/lib/python3.6/site-packages/opensearchpy/client/indices.py", line 125, in create
"PUT", _make_path(index), params=params, headers=headers, body=body
File "/usr/local/lib/python3.6/site-packages/opensearchpy/transport.py", line 405, in perform_request
raise e
File "/usr/local/lib/python3.6/site-packages/opensearchpy/transport.py", line 375, in perform_request
timeout=timeout,
File "/usr/local/lib/python3.6/site-packages/opensearchpy/connection/http_urllib3.py", line 261, in perform_request
raise SSLError("N/A", str(e), e)
opensearchpy.exceptions.SSLError: ConnectionError([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)) caused by: SSLError([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897))
[root#ip-10-92-3-240 pyscripts]#
Not sure what's wrong I am using the same certificate in opensearch-dashboard.yml file, but can't connect using python client.
Any suggestion would be really helpful.
Thanks
Related
I was trying to run some code that I was able to run in the past with the following error. I tried to uninstalling yfinance and installing it again, upgrading yfinance, and the solution in the following link:
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\limon\Anaconda3\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\limon\Anaconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\multitasking\__init__.py", line 102, in _run_via_pool
return callee(*args, **kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\yfinance\multi.py", line 169, in _download_one_threaded
data = _download_one(ticker, start, end, auto_adjust, back_adjust,
File "C:\Users\limon\Anaconda3\lib\site-packages\yfinance\multi.py", line 181, in _download_one
return Ticker(ticker).history(period=period, interval=interval,
File "C:\Users\limon\Anaconda3\lib\site-packages\yfinance\base.py", line 152, in history
data = self.session.get(
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))
Already tried this solutions as well:
sudo python3 -m pip install --upgrade yfinance
As well as solution from this link:
https://pypi.org/project/fix-yahoo-finance/
I am trying to run a simple telegram bot code via python and i keep getting this error. I am fairly new to python and just cant get to understand even some of the online solutions proposed. I am not sure on how i should get the SSL certificate installed if at all that is the problem.
import telebot
bot = telebot.TeleBot("TOKEN")
#bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
bot.reply_to(message, "Hello, how are you doing?")
#bot.message_handler(func=lambda message: True)
def echo_all(message):
bot.reply_to(message, message.text)
bot.polling()
Here is the Traceback for reference:
2020-03-26 12:48:57,541 (util.py:66 PollingThread) ERROR - TeleBot: "SSLError occurred, args=(SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')),)
Traceback (most recent call last):
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 761, in _validate_conn
conn.connect()
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 279, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\adapters.py", line 370, in send
timeout=timeout
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 574, in urlopen
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\telebot\util.py", line 60, in run
task(*args, **kwargs)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\telebot\__init__.py", line 279, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\telebot\__init__.py", line 249, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\telebot\apihelper.py", line 194, in get_updates
return _make_request(token, method_url, params=payload)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\telebot\apihelper.py", line 58, in _make_request
timeout=(connect_timeout, read_timeout), proxies=proxy)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\adapters.py", line 431, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
"
Traceback (most recent call last):
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 761, in _validate_conn
conn.connect()
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 279, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Users\1025632\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
# Imports the Google Cloud client library
from google.cloud import translate
# Instantiates a client
translate_client = translate.Client()
# The text to translate
text = u'Hello, world!'
# The target language
target = 'ru'
# Translates some text into Russian
translation = translate_client.translate(
text,
target_language=target)
print(u'Text: {}'.format(text))
print(u'Translation: {}'.format(translation['translatedText']))
I use google translation api of python version demo,and find that the method translate_client.translate allways throws timeout excption ,what is wrong with this?timeout when the method called.
Traceback (most recent call last):
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
conn.connect()
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connection.py", line 344, in connect
ssl_context=context)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\util\ssl_.py", line 344, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 850, in _create
self.do_handshake()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1108, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\util\retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
conn.connect()
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\connection.py", line 344, in connect
ssl_context=context)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\urllib3\util\ssl_.py", line 344, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 850, in _create
self.do_handshake()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1108, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(0, 'Error'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/untitled5/translatetest.py", line 15, in
print(u'Text: {}'.format(text))
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\google\cloud\translate_v2\client.py", line 233, in translate
method='POST', path='', data=data)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\google\cloud_http.py", line 290, in api_request
headers=headers, target_object=_target_object)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\google\cloud_http.py", line 183, in _make_request
return self._do_request(method, url, headers, data, target_object)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\google\cloud_http.py", line 212, in _do_request
url=url, method=method, headers=headers, data=data)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\google\auth\transport\requests.py", line 201, in request
method, url, data=data, headers=request_headers, **kwargs)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Administrator\PycharmProjects\untitled5\venv\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError(0, 'Error'))
Using Python 3.4, I installed the below geolocation package
https://pypi.python.org/pypi/geolocation-python/0.2.2
I tested it in IDLE using the code below
key = 'myGoogleKey'
google = GoogleMaps(api_key=key)
addr = 'Boston MA'
location = google.search(location=addr)
it fails at the last line, generating an SSL Error
Traceback (most recent call last):
File "c:\python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 559, in urlopen
body=body, headers=headers)
File "c:\python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 345, in _make_request
self._validate_conn(conn)
File "c:\python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 782, in _validate_conn
conn.connect()
File "c:\python34\lib\site-packages\requests\packages\urllib3\connection.py", line 250, in connect
ssl_version=resolved_ssl_version)
File "c:\python34\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 285, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "c:\python34\lib\ssl.py", line 365, in wrap_socket
_context=self)
File "c:\python34\lib\ssl.py", line 583, in __init__
self.do_handshake()
File "c:\python34\lib\ssl.py", line 810, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\python34\lib\site-packages\requests\adapters.py", line 370, in send
timeout=timeout
File "c:\python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 588, in urlopen
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
location = google.search(location=addr)
File "c:\python34\lib\site-packages\geolocation\main.py", line 18, in search
return self.geocode.search(location, lat, lng)
File "c:\python34\lib\site-packages\geolocation\geocode\main.py", line 48, in search
data = self.client.get_data(address=address, latitude=latitude, longitude=longitude)
File "c:\python34\lib\site-packages\geolocation\geocode\client.py", line 40, in get_data
return self.send_data(self.API_URL, self.query_parameters)
File "c:\python34\lib\site-packages\geolocation\client.py", line 22, in send_data
response = requests.get(url, params=params)
File "c:\python34\lib\site-packages\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "c:\python34\lib\site-packages\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "c:\python34\lib\site-packages\requests\sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "c:\python34\lib\site-packages\requests\sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "c:\python34\lib\site-packages\requests\adapters.py", line 433, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)
I used this same package and code using python 2.7 in a linux environment and it worked fine. Any ideas on how I can fix this?
import requests
spiders = requests.get('https://en.wikipedia.org/w/api.php')
print(spiders)
With above code I am getting following error:
Traceback (most recent call last):
File "C:\Python\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 554, in urlopen
self._prepare_proxy(conn)
File "C:\Python\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 750, in _prepare_proxy
conn.connect()
File "C:\Python\lib\site-packages\requests\packages\urllib3\connection.py", line 252, in connect
ssl_version=resolved_ssl_version)
File "C:\Python\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 305, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Python\lib\ssl.py", line 376, in wrap_socket
_context=self)
File "C:\Python\lib\ssl.py", line 747, in __init__
self.do_handshake()
File "C:\Python\lib\ssl.py", line 983, in do_handshake
self._sslobj.do_handshake()
File "C:\Python\lib\ssl.py", line 628, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
Using a certificate I still get an error:
import requests
spiders = requests.get('https://en.wikipedia.org/w/api.php',cert = 'c:\python\lib\site-packages\certifi\cacert.pem',verify = True)
print(spiders)
Traceback (most recent call last):
File "C:/Python/Files/3.py", line 3, in <module>
spiders = requests.get('https://en.wikipedia.org/w/api.php',cert = 'c:\python\lib\site-packages\certifi\cacert.pem',verify = True)
File "C:\Python\lib\site-packages\requests\api.py", line 67, in get
return request('get', url, params=params, **kwargs)
File "C:\Python\lib\site-packages\requests\api.py", line 53, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python\lib\site-packages\requests\sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python\lib\site-packages\requests\sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "C:\Python\lib\site-packages\requests\adapters.py", line 447, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL] PEM lib (_ssl.c:2824)
Even when I have followed some tutorial verbatim I have encountered this issue when the instructor would have access w/o issue. Any ideas?
u can ignore SSL like this:
import requests
spiders = requests.get('https://en.wikipedia.org/w/api.php',verify = False)
print(spiders)
other solution:
from urllib.request import Request, urlopen
rq = Request('https://en.wikipedia.org/w/api.php')
response = urlopen(rq).read()