SSL certificate expired error for influxdb-client - python-3.x

I have a windows 10 machine, and I am not sure what the problem is, I was able to run everything until a few hours back and now I keep running into SSL certificate Expired error for some reason.
Steps to reproduce:
This is my code.
'''
'''
from datetime import datetime
from influxdb_client import InfluxDBClient
config = {
'start': datetime.date(datetime(2021, 4, 7)),
'stop': datetime.date(datetime(2021, 4, 10)),
'bucket': "hidden",
'org': "hidden",
'url': "hidden",
'token': "hidden",
'measurement-name': "hidden",
}
client = InfluxDBClient(
url="https://eu-central-1-1.aws.cloud2.influxdata.com",
org=config['org'],
bucket=config['bucket'],
token=config['token'],
# verify_ssl=False
)
query_api = client.query_api()
ticker = 'TSLA'
results_df = query_api.query_data_frame(
f'from(bucket:"{config["bucket"]}")'
f'|> range(start: {config["start"]}, stop: {config["stop"]}) '
'|> filter(fn: (r) =>'
f' r._measurement == "{config["measurement-name"]}"'
f' and r.symbol == "{ticker}"'
') '
'|> filter (fn: (r) =>'
' r._field == "price"'
') '
'|> pivot('
' rowKey:["_time"],'
' columnKey: ["_field"],'
' valueColumn: "_value"'
') '
'|> sort(columns: ["_time"], desc: false) '
)
print(results_df)
Expected behavior:
I expect it to give me a dataframe like it always does and as you can see when I keep the ssl_verify=False it works.
result table _time _start _stop _measurement source symbol price
0 _result 0 2021-04-07 00:00:00+00:00 2021-04-07 00:00:00+00:00 2021-04-08 00:00:00+00:00 public_instruments_data YAHOO-FINANCE TSLA 670.969971
Actual behavior:
Traceback (most recent call last):
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "d:\MAIN_ENV\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\rest.py", line 181, in request
r = self.pool_manager.request(
File "d:\MAIN_ENV\lib\site-packages\urllib3\request.py", line 78, in request
return self.request_encode_body(
File "d:\MAIN_ENV\lib\site-packages\urllib3\request.py", line 170, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "d:\MAIN_ENV\lib\site-packages\urllib3\poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\retry.py", line 507, in increment
raise six.reraise(type(error), error, _stacktrace)
File "d:\MAIN_ENV\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
raise value.with_traceback(tb)
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "d:\MAIN_ENV\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "d:\MAIN_ENV\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "d:\MAIN_ENV\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\khans\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\backend-dev-plaid\test_app_5.py", line 26, in <module>
results_df = query_api.query_data_frame(
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\client\query_api.py", line 146, in query_data_frame
_generator = self.query_data_frame_stream(query, org=org, data_frame_index=data_frame_index, params=params)
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\client\query_api.py", line 172, in query_data_frame_stream
response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect, params),
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\service\query_service.py", line 260, in post_query
(data) = self.post_query_with_http_info(**kwargs) # noqa: E501
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\service\query_service.py", line 340, in post_query_with_http_info
return self.api_client.call_api(
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\api_client.py", line 341, in call_api
return self.__call_api(resource_path, method,
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\api_client.py", line 171, in __call_api
response_data = self.request(
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\api_client.py", line 386, in request
return self.rest_client.POST(url,
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\rest.py", line 302, in POST
return self.request("POST", url,
File "d:\MAIN_ENV\lib\site-packages\influxdb_client\rest.py", line 238, in request
raise ApiException(status=0, reason=msg)
influxdb_client.rest.ApiException: (0)
Reason: SSLError
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)
Specifications:
Client Version: 1.21.0
InfluxDB Version: 2.0
Platform: Windows 10 home
Python: 3.9.7
I tried reinstalling python and all the libraries again just make sure the problem wasn't at my end and I also followed the urllib3 docs for installing the certificates from certifi and urllib3[secure] as suggested when I keep ssl_verify=False.
Any help would be much appreciated, thanks a lot in advance.

Just use ..., ssl_ca_cert=certifi.where(), ... as a temporary solution, but anyways since posting the question it seems the certificates have been already updated.

Related

I am getting 'Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', N one, 10054, None)

This is part of the code where i am requesting web server.
I am writing a code to get posters of the movies from tmdb database using movie_id.
def fetch_poster(movie_id):
response = requests.get("https://api.themoviedb.org/3/movie/{}?api_key=8265bd1679663a7ea12ac168da84d2e8&language=en-US".format(movie_id))
data = response.json()
return "https://image.tmdb.org/t/p/w500/" + data['poster_path']
This is the error i am getting.
[error 10054 - connection was forcibly interrupted by the remote host]. I am getting this error many times.
2022-05-26 16:26:21.708 Traceback (most recent call last):
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\requests\adapters.py", line 440, in send
resp = conn.urlopen(
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\util\retry.py", line 550, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
raise value.with_traceback(tb)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', N
one, 10054, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 475, in _run_script
exec(code, module.__dict__)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\application.py", line 239, in <module>
rec_content_movies, rec_content_posters = content_filtering(selected_movie_name)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\application.py", line 41, in content_filtering
content_posters.append(fetch_poster(movie_id))
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\application.py", line 23, in fetch_poster
response = requests.get("https://api.themoviedb.org/3/movie/{}?api_key=8265bd1679663a7ea12ac168da84d2e8&language=en-US".format(movie_id))
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\requests\sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\requests\sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "C:\Users\admin\OneDrive\Desktop\Project\Recom_engine\venv\lib\site-packages\requests\adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host'
, None, 10054, None))
Can anyone help me out?

Bigcommerce API connection disconnects with no response

We've been using a Python script to pull orders from our BigCommerce store and reformat them into a .csv for use by our warehouse. This method has been working for the past 3 years yet since the 16 September 2020 our connection has started dropping without a response.
Full response is:
Downloading Order: 1541
WPy64-3720\python-3.7.2.amd64\python.exe : Traceback (most recent call last):
At D:\Administration\Scripts\re_orders\reau-orders.ps1:7 char:28
+ $OrdersProcessingOutput = (WPy64-3720\python-3.7.2.amd64\python.exe bcOrdersREAU ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 386, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 382, in _make_request
httplib_response = conn.getresponse()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 1321, in
getresponse
response.begin()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 265, in
_read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Administration\Scripts\re_orders\requests\adapters.py", line 438, in send
timeout=timeout
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\util\retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 386, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "D:\Administration\Scripts\re_orders\requests\packages\urllib3\connectionpool.py", line 382, in _make_request
httplib_response = conn.getresponse()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 1321, in
getresponse
response.begin()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\http\client.py", line 265, in
_read_status
raise RemoteDisconnected("Remote end closed connection without"
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed
connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bcOrdersREAU.py", line 1254, in <module>
checkPendingPayments(basePath + pendingPayFile)
File "bcOrdersREAU.py", line 915, in checkPendingPayments
getOrders(orderId,orderId)
File "bcOrdersREAU.py", line 249, in getOrders
orderJSON = getOrder(headers,orderNo)
File "D:\Administration\Scripts\re_orders\tenacity\__init__.py", line 333, in wrapped_f
return self(f, *args, **kw)
File "D:\Administration\Scripts\re_orders\tenacity\__init__.py", line 417, in __call__
do = self.iter(retry_state=retry_state)
File "D:\Administration\Scripts\re_orders\tenacity\__init__.py", line 360, in iter
return fut.result()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\concurrent\futures\_base.py", line 425,
in result
return self.__get_result()
File "D:\Administration\Scripts\re_orders\WPy64-3720\python-3.7.2.amd64\lib\concurrent\futures\_base.py", line 384,
in __get_result
raise self._exception
File "D:\Administration\Scripts\re_orders\tenacity\__init__.py", line 420, in __call__
result = fn(*args, **kwargs)
File "bc
OrdersREAU.py", line 1155, in getOrder
order = session.get(ApiPath2 + 'orders/' + str(orderNo), headers=headers)
File "D:\Administration\Scripts\re_orders\requests\sessions.py", line 531, in get
return self.request('GET', url, **kwargs)
File "D:\Administration\Scripts\re_orders\requests\sessions.py", line 518, in request
resp = self.send(prep, **send_kwargs)
File "D:\Administration\Scripts\re_orders\requests\sessions.py", line 639, in send
r = adapter.send(request, **kwargs)
File "D:\Administration\Scripts\re_orders\requests\adapters.py", line 488, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without
response'))
The code we're using runs daily and is essentially just iterating through new orders and pulling the details down, including the ordered products. Something like:
requests.get(ApiPath2 + 'orders/' + str(orderNo), headers=headers)
session.get(ApiPath2 + 'orders/' + str(orderNo) + '/products?page=' + str(page), headers=headers)
It doesn't fail every day but has started to be almost a daily occurrence now.
What we have tried:
new API credentials
different servers on a different network (Aus + Europe)
Running the script at different times
Any help would be greatly appreciated. Currently we just keep re running the code manually until it works.
Per python docs
self.send_header('Content-Type', 'blabla' )
self.end_headers()

selenium alert automatically click accept with IE driver

In such this situation:
there is a list on the page
below it have one check for check all of the list item,and a div to receive all of the list,
after click it will pop up a alert,after click accept the page will close.
onclick=checkedalldoc();#check
onclick=responseclick();#div
I need use selenium with IE to automatically these
this is my basepage.py for packaging code:
# 点击元素
def click(self, *selector):
el = self.find_element(*selector)
try:
el.click()
logger.info('元素'%s' 已被点击.' % el.text)
except NameError as e:
logger.error('Failed to click the element with %s' % e)
#运行js脚本
def run_script(self, js):
try:
self.driver.execute_script(js)
logger.info('成功运行脚本,脚本内容为:%s.' % js)
except BaseException:
logger.error('js脚本运行错误.')
#切换至弹窗并点击确定
def accept_alert(self):
try:
WebDriverWait(self.driver, 20).until(EC.alert_is_present())
alert = self.driver.switch_to.alert
alert.accept()
logger.info('获得弹出框并选择确认.')
except BaseException:
logger.error('弹出框失败.')
this is logic function
def receive_all_docs(self):
self.click(*self.chkall_checkbox)
self.click(*self.response_btn)
self.accept_alert()
When it works, it prompts the following error and it does not complete the function:
Traceback (most recent call last):
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "c:\users\a\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "e:\Dropbox\17.Develop\5.Project\autozboa\run.py", line 22, in <module>
manage()
File "e:\Dropbox\17.Develop\5.Project\autozboa\run.py", line 14, in manage
m.handle_doc() # 处理单个文件
File "e:\Dropbox\17.Develop\5.Project\autozboa\manage.py", line 67, in handle_doc
docs_unid = docs.get_docs_unid()
File "e:\Dropbox\17.Develop\5.Project\autozboa\zboa\pages\docs_page.py", line 38, in get_docs_unid
for doc in self.find_elements(*self.docs_link):
File "e:\Dropbox\17.Develop\5.Project\autozboa\zboa\framework\base_page.py", line 70, in find_elements
elements = self.driver.find_elements(*selector)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1005, in find_elements
return self.execute(Command.FIND_ELEMENTS, {
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 402, in _request
resp = http.request(method, url, body=body, headers=headers)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\request.py", line 79, in request
return self.request_encode_body(
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\request.py", line 171, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\poolmanager.py", line 330, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\util\retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "E:\Dropbox\17.Develop\5.Project\autozboa\env\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "c:\users\a\appdata\local\programs\python\python38\lib\http\client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "c:\users\a\appdata\local\programs\python\python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))
i would try two things here
first, syntax:
as described in selenium-python docs, accepting alert is done by:
from selenium.webdriver.common.alert import Alert
Alert(driver).accept()
second, you should check exectly which row produces the exception.
UnexpectedAlertPresentException occurs when you are trying to preform an action while an alert is open. is it possible that those "click" actions are called when an alert is already open?

requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')

Anyone has an idea how I can solve this error?
I am trying to download data and I have connected a posgresql server with the database navigator as localhost. Files are successfully downloaded for like 3 minutes and than suddenly the download stops and returns this error message:
.
..
...
run_filing 201500419349300305
run_filing 201540439349301594
Traceback (most recent call last):
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Georg/PycharmProjects/990-xml-database/irsdb/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/Users/Georg/PycharmProjects/990-xml-database/irsdb/return/management/commands/load_filings.py", line 123, in handle
self.run_filing(filing)
File "/Users/Georg/PycharmProjects/990-xml-database/irsdb/return/management/commands/load_filings.py", line 65, in run_filing
parsed_filing = self.xml_runner.run_filing(object_id)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/irsx/xmlrunner.py", line 111, in run_filing
this_filing.process(verbose=verbose)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/irsx/filing.py", line 232, in process
self._download(verbose=verbose)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/irsx/filing.py", line 70, in _download
stream_download(self.URL, self.filepath, verbose=verbose)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/irsx/file_utils.py", line 22, in stream_download
response = requests.get(url, stream=True)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/Georg/PycharmProjects/990-xml-database/venv/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
Attached is a screenshot of the connectionpool.py code.

Certificate Error when using wikipedia API in python 3.7

When I'm trying to use the Wikipedia API, I get a certificate error message.
This for an assistant I am coding on a school computer and I think it is something that has been put there by administration as I got a certificate error when using NPM previously.
Here is the code I am using:
wikiSearch = query.strip("wiki ")
outputs = wikipedia.summary(wikiSearch, sentences=3)
I thought this would return the first three sentences of the article as it does in python 2.7 but instead returns this lengthy error message:
Traceback (most recent call last):
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/urllib3/connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
conn.connect()
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/urllib3/connection.py", line 350, in connect
ssl_context=context)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/urllib3/util/ssl_.py", line 355, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /w/api.php?list=search&srprop=&srlimit=1&limit=1&srsearch=alex&srinfo=suggestion&format=json&action=query (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "dave.py", line 54, in <module>
index()
File "dave.py", line 24, in index
outputs = wikipedia.summary(wikiSearch, sentences=3)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/util.py", line 28, in __call__
ret = self._cache[key] = self.fn(*args, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/wikipedia.py", line 231, in summary
page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/wikipedia.py", line 270, in page
results, suggestion = search(title, results=1, suggestion=True)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/util.py", line 28, in __call__
ret = self._cache[key] = self.fn(*args, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/wikipedia.py", line 103, in search
raw_results = _wiki_request(search_params)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/wikipedia.py", line 737, in _wiki_request
r = requests.get(API_URL, params=params, headers=headers)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/sessions.py", line 668, in send
history = [resp for resp in gen] if allow_redirects else []
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/sessions.py", line 668, in <listcomp>
history = [resp for resp in gen] if allow_redirects else []
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/sessions.py", line 247, in resolve_redirects
**adapter_kwargs
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='en.wikipedia.org', port=443): Max retries exceeded with url: /w/api.php?list=search&srprop=&srlimit=1&limit=1&srsearch=alex&srinfo=suggestion&format=json&action=query (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
Edit:
I now get this error:
File "/Users/alexander.hawking/Desktop/Dave/dave.py", line 84, in <module>
index()
File "/Users/alexander.hawking/Desktop/Dave/dave.py", line 26, in index
outputs = wikipedia.summary(wikiSearch, sentences=3)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/util.py", line 28, in __call__
ret = self._cache[key] = self.fn(*args, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/wikipedia.py", line 231, in summary
page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/wikipedia.py", line 270, in page
results, suggestion = search(title, results=1, suggestion=True)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/util.py", line 28, in __call__
ret = self._cache[key] = self.fn(*args, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/wikipedia.py", line 103, in search
raw_results = _wiki_request(search_params)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/wikipedia/wikipedia.py", line 737, in _wiki_request
r = requests.get(API_URL, params=params, headers=headers)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/alexander.hawking/Library/Python/3.7/lib/python/site-packages/requests/adapters.py", line 510, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPConnectionPool(host='myproxy.proxy.com', port=1234): Max retries exceeded with url: http://en.wikipedia.org/w/api.php?list=search&srprop=&srlimit=1&limit=1&srsearch=alex&srinfo=suggestion&format=json&action=query (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10e2d3eb8>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')))
As you have mentioned that you encountered a similar error when you were working with NPM, it's most likely due to the proxy setup by your administration.
You can configure the proxy for any third party module to connect to the internet. By default, urlopen of urllib3 uses the environment variable http_proxy to determine which HTTP proxy to use.
run this command in CMD before running your python application
export http_proxy='http://myproxy.proxy.com:1234'
============================================================
if you don't know your proxy you can try this workaround.
run this command in CMD before running the python application
export CURL_CA_BUNDLE=''
or add these lines to your code to avoid adding environment variable manually every time.
import os
os.environ['CURL_CA_BUNDLE'] = ""
if you are getting InsecureRequestWarning and you want to suppress it you can do the following.
import wikipedia
import os
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
os.environ['CURL_CA_BUNDLE'] = ""
os.environ['PYTHONWARNINGS']="ignore:Unverified HTTPS request"
print(wikipedia.wikipedia.summary("Google"))
I hope this helps.

Resources