I am trying to execute a REST get call using 'requests' library, and i am using python 3.10 on ubuntu
But I get the exception:
requests.exceptions.ProxyError: HTTPSConnectionPool(host='XXX', port=443): Max retries exceeded with url: XXX (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 503 Service Unavailable')))
I set environment variables in persistence file .bashrc :
enter image description here and I added HTTP_PROXY variable too.
I tried sending proxies variable in the request but I get the same exception
enter image description here
In the requests library documentation I coun't find any information about this exception.
This worked for me
requests.packages.urllib3.disable_warnings()
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL'
try:
requests.packages.urllib3.contrib.pyopenssl.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL'
except AttributeError:
# no pyopenssl support used / needed / available
pass
Then call: r = requests.get(url, headers=headers, timeout=3, verify=False)
Related
Hello I have just tried using this code but still getting error. Any idea how to solve this?
I have referred similar post also but it is not working.
import hvac
client = hvac.Client(url='https://vault.xyz.com:1100/ui')
response = client.secrets.kv.v2.read_secret_version(path='/secrets/secret/show/ab/ss/dd')
Error-
raise_for_error raise exceptions.Forbidden(message, errors=errors, method=method, url=url) hvac.exceptions.Forbidden: 1 error occurred: * permission denied
I am using Poetry version 1.1.7.
Running poetry install yields this error.
Can this be resolved through bash or is this explicitly to do with my network? Note: Internet connectivity it perfectly fine in browsers.
me#LAPTOP-G1DAPU88:~/.ssh/workers-python/workers/CompositeKey/CompositeKey$ poetry install
Updating dependencies
Resolving dependencies... (225.5s)
ConnectionError
HTTPSConnectionPool(host='pkgs.dev.azure.com', port=443): Max retries exceeded with url: <CENSORED> (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f53950c3ee0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))
at ~/.poetry/lib/poetry/_vendor/py3.8/requests/adapters.py:516 in send
512│ if isinstance(e.reason, _SSLError):
513│ # This branch is for urllib3 v1.22 and later.
514│ raise SSLError(e, request=request)
515│
→ 516│ raise ConnectionError(e, request=request)
517│
518│ except ClosedPoolError as e:
519│ raise ConnectionError(e, request=request)
520│
A 401 Unauthorized Error is thrown when pasting the URL into my browser.
I did:
poetry self update 1.0.10
poetry install
Terminal is giving me installs now, as it should.
me#LAPTOP-G1DAPU88:~/.ssh/workers-python/workers/CompositeKey/CompositeKey$ poetry self update 1.0.10
Updating to 1.0.10
- Downloading poetry-1.0.10-linux.tar.gz 100%
Poetry (1.0.10) is installed now. Great!
me#LAPTOP-G1DAPU88:~/.ssh/workers-python/workers/CompositeKey/CompositeKey$ poetry install
Updating dependencies
Resolving dependencies... (101.5s)
Writing lock file
Package operations: 167 installs, 0 updates, 0 removals
- Installing six (1.16.0)
...
I have the same issue and it turns out to be connection refused by server due to exceeding the max connections limit of the mirror repo.
By default poetry's max installer.max-workers is set to number_of_cores + 4. This would be a problem when you run poetry on a server with like 24 cores and it is reasonable for the server side to refuse that many of connections.
The work around is to config this value manually before executing poetry install, you can use the following command to do limit the max connections:
poetry config installer.max-workers 4
OS: Windows 10
tensorflow and keras succesfully imported, python 3.7.9
tf.__version__
>>> '2.1.0'
keras.__version__
>>> '2.2.4-tf'
Problem
Tried load_datasets or any dataset available in tf.keras such as:
(train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.fashion_mnist.load_data()
give this error
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
.
.
.
URLError: <urlopen error [WinError 10054] An existing connection was forcibly closed by the remote host>
During handling of the above exception, another exception occurred:
.
.
.
Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-
idx1-ubyte.gz: None -- [WinError 10054] An existing connection was forcibly closed by the remote host
The three dots showing bunch of code lines that can't be executed.
Anyone knows how to solve? I've been looking for possible solutions but the closest I can find is solving certification/verification issue, I think mine is about URL.
I know the workaround is to download the dataset from kaggle etc., but I want to know what cause this. Thanks guys
EDIT: it's not URL problem, unable to access https://storage.googleapis.com using IDM, but files can be downloaded directly in browser. So I guess it's security issue
Finally after 5 hours reading here and there..
Please check the solution by CRLannister here https://github.com/tensorflow/tensorflow/issues/33285
What it doesn't mention is where data_utils.py is located in case of Windows OS and anaconda environment. It's located here
~\Anaconda3\envs\*your_env*\Lib\site-packages\tensorflow_core\python\keras\utils\data_utils.py
just add the following after all the import statement
import requests
requests.packages.urllib3.disable_warnings()
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context
I'm trying to do a FTPS (or FTP) connection to a FTP server. This is done on Python 3.8.5 32 bit via Visual Studio Code.
Here is the code:
import ftplib
session = ftplib.FTP_TLS('server address')
#session.connect ('server address', 991)
session.login(user='username',passwd='password')
#session.prot_p()
session.set_pasv(True)
session.cwd("files")
print(session.pwd())
filename = "ftpTest.txt"
my_file = open('filepath\\ftpTest.txt', 'wb') # Open a local file to store the downloaded file
session.retrbinary('RETR ' + filename, my_file.write, 1024)
session.quit()
I am able to get the session.pwd (which display /files) but the connection timeout at line 11 (session.retrbinary) in approximately 22 sec with the following error:
Exception has occurred: 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
I had tried setting session.set_pasv to both True and False following Python ftplib timing out. Setting it True raised the TimeoutError and setting it False raise the following error at line 11:
Exception has occurred: error_perm
500 Illegal PORT command
and also tried setting a different port (991) following Python SSL FTP connection timing out and it raised the Timeout Error at line 3.
Using FTP without TLS raised the following error at line 4 (session.login):
Exception has occurred: error_perm
530 Non-anonymous sessions must use encryption.
Turning off my McAfee LiveSafe firewall didnt help either.
Btw file transfer works with Filezilla, was able to freely transfer.
Setting up the secure data connection and changing the session af to INET6 seemed to work for me. This was suggested to me by a colleague, and as to why it works is beyond me. If anyone can provide a proper explanation, please do.
Code:
session.login(user='username',passwd='password')
session.prot_p()
session.af = socket.AF_INET6
I'm using the this module [1]: https://github.com/kragniz/python-etcd3 to communicate with etcdv3. I have created all the necessary certs and tested client secure connection with curl. However atempting a simple get operation fails. Code snippet and exception below.
import etcd3
ca='/Users/PKI/etcd/ca.pem'
cert='/Users/PKI/etcd/client.pem'
key='/Users/PKI/etcd/client-key.pem'
etcd = etcd3.client(ca_cert=ca, cert_cert=cert, cert_key=key)
etcd.get('foo')
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"#1594500226.366466000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3948,"referenced_errors":[{"created":"#1594500226.366461000","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":394,"grpc_status":14}]}"
>
> /usr/local/lib/python3.8/site-packages/etcd3/client.py(46)handler()
-> return f(*args, **kwargs)
I haven't done much with grpc so I'm not sure if there are options I should pass to init the etcd3 client.