import boto3
aws_mag_con = boto3.session.Session(aws_access_key_id='xxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxxxxxxx')
newec2 = aws_mag_con.client('ec2','us-east-1c',aws_access_key_id='xxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxxxx')
conn = newec2.run_instances(InstanceType="t2.micro",MaxCount=1,MinCount=1,ImageId="ami-0e1d30f2c40c4c701")
Tried to create instance by running the above boto3 script. It is failing with below error. Any help on this?
Traceback (most recent call last):
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\socket.py", line 953, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\httpsession.py", line 403,
in send
urllib_response = conn.urlopen(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 525, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\packages\six.py", line 770,
in reraise
raise value
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 358, in connect
conn = self._new_conn()
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <botocore.awsrequest.AWSHTTPSConnection object at 0x000001AEE1E48E80>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\va20054093\Desktop\Stud\Python\.vscode\.vscode\runinstance.py", line 9, in <module>
conn = newec2.run_instances(InstanceType="t2.micro",MaxCount=1,MinCount=1,ImageId="ami-0e1d30f2c40c4c701")
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 391, in _api_call
return self._make_api_call(operation_name, kwargs)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 705, in _make_api_call
http, parsed_response = self._make_request(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 725, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 104, in
make_request
return self._send_request(request_dict, operation_model)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 138, in
_send_request
while self._needs_retry(attempts, operation_model, request_dict,
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 254, in
_needs_retry
responses = self._event_emitter.emit(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 357, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 211, in _emit
response = handler(**kwargs)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 250, in __call__
should_retry = self._should_retry(attempt_number, response,
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 316, in __call__
checker_response = checker(attempt_number, response,
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 222, in __call__
return self._check_caught_exception(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 359, in _check_caught_exceptionexception
raise caught_exception
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 201, in _do_get_response
http_response = self._send(request)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 270, in _send
return self.http_session.send(request)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\httpsession.py", line 432, in send
raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.us-east-1c.amazonaws.com/"
The error says:
Could not connect to the endpoint URL: "https://ec2.us-east-1c.amazonaws.com/"
The region is named us-east-1, while an AZ is named us-east-1c.
The error is in this line:
newec2 = aws_mag_con.client('ec2','us-east-1c',aws_access_key_id='xxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxxxx')
Change us-east-1c into us-east-1.
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 integration tests using boto3 and aws. It seems the tests are unable to connect to the localhost endpoint so the tests are failing. I'm quite sure I've configured my aws environment variables correctly. I suspect that maybe there is no local server running but I'm still unsure how to fix the problem. Any help would be greatly appreciated.
I'm running on Mac Mojave, I've tried changing the ports that the server is attempting to connect to localhost:3000. I've also tried connecting to a server that I'm running using AWS Step Functions (https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local-config-options.html) but with no luck.
Error messages from Log:
ConnectionRefusedError: [Errno 61] Connection refused
and
raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:3001/2015-03-31/functions/AthenaDatabaseProvider/invocations"
Complete Log:
Traceback (most recent call last):
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/util/connection.py", line 80, in create_connection
raise err
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/util/connection.py", line 70, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/httpsession.py", line 262, in send
chunked=self._chunked(request.headers),
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/util/retry.py", line 344, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1244, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/awsrequest.py", line 125, in _send_request
method, url, body, headers, *args, **kwargs)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1290, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1239, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/awsrequest.py", line 152, in _send_output
self.send(msg)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/awsrequest.py", line 236, in send
return super(AWSConnection, self).send(str)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connection.py", line 183, in connect
conn = self._new_conn()
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <botocore.awsrequest.AWSHTTPConnection object at 0x11ea50d90>: Failed to establish a new connection: [Errno 61] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/patrickward/repositories/JAM/hobbes/transformations/tests/integration/lambdas/athena_database_provider_test.py", line 97, in test_drop_with_stack_false_keeps_database_on_delete
invoke_fn(cloud_formation_event('Delete', DatabaseName=existent_database, DropWithStack='False'))
File "/Users/patrickward/repositories/JAM/hobbes/transformations/tests/integration/lambdas/athena_database_provider_test.py", line 54, in _exec
Payload=json.dumps(event)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/client.py", line 648, in _make_api_call
operation_model, request_dict, request_context)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/client.py", line 667, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 102, in make_request
return self._send_request(request_dict, operation_model)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 137, in _send_request
success_response, exception):
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 231, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
response = handler(**kwargs)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 200, in _do_get_response
http_response = self._send(request)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/endpoint.py", line 244, in _send
return self.http_session.send(request)
File "/Users/patrickward/.local/share/virtualenvs/hobbes-iOpBOaJm/lib/python3.7/site-packages/botocore/httpsession.py", line 282, in send
raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://127.0.0.1:3001/2015-03-31/functions/AthenaDatabaseProvider/invocations"
Turns out I need to have the docker app running when I run tests. Hope this can help someone who might have run into the same problem!
# 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'))
I'm new to python and I have trouble analysing the following errors. Does someone know why my script crashed?
I'm scraping the web for some data and everytime the scraper hits, the script writes that time into database (to check if the script is still alive). Every couple of days the script crashes.
Thanks in advance.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 356, in connect
ssl_context=context)
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 359, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/local/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/usr/local/lib/python3.7/ssl.py", line 850, in _create
self.do_handshake()
File "/usr/local/lib/python3.7/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 "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 356, in connect
ssl_context=context)
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 359, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/local/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/usr/local/lib/python3.7/ssl.py", line 850, in _create
self.do_handshake()
File "/usr/local/lib/python3.7/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 "/usr/local/lib/python3.7/site-packages/firebase_admin/db.py", line 881, in request
return super(_Client, self).request(method, url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/firebase_admin/_http_client.py", line 84, in request
resp = self._session.request(method, self._base_url + url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/auth/transport/requests.py", line 201, in request
method, url, data=data, headers=request_headers, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 495, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError(0, 'Error'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./main.py", line 32, in <module>
firebase.write_time_stamp(for_js)
File "/firebase.py", line 38, in write_time_stamp
'time': stamp
File "/usr/local/lib/python3.7/site-packages/firebase_admin/db.py", line 339, in update
self._client.request('patch', self._add_suffix(), json=value, params='print=silent')
File "/usr/local/lib/python3.7/site-packages/firebase_admin/db.py", line 883, in request
raise ApiCallError(_Client.extract_error_message(error), error)
firebase_admin.db.ApiCallError: ('Connection aborted.', OSError(0, 'Error'))
I'm having some issues with my raspberry setup.
The test:
# -*- coding: utf-8 -*-
import requests
import json
firebase_url = 'https://myDb.firebaseio.com'
name = 'db_name'
test = {}
print(firebase_url + '/' + name + '/setup.json')
test = requests.get(firebase_url + '/' + name + '/setup.json')
test = test.json()
print(test)
Runs on my laptop with no problems. On the Raspberry Pi I get this:
https://myDb.firebaseio.com/db_name/setup.json
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 304, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 724, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 203, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 133, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 64, in create_connection
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 362, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 559, in urlopen
_pool=self, _stacktrace=stacktrace)
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 245, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 624, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 304, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 724, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 203, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 133, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 64, in create_connection
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
urllib3.exceptions.ProtocolError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test_fire.py", line 11, in <module>
test = requests.get(firebase_url + '/' + name + '/setup.json')
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in get
return request('get', url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 407, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
I get that it means that it can't connect. Why it can't connect is another question though. I'm running this test while logged in over SSH with weaved. So internet is up and running without any problems. I feel like I'm missing something obvious but I just don't know where to look.
Thanks!
It was a DNS problem and everything was fixed by adding nameserver 8.8.8.8 to /etc/resolv.conf...
Case closed.