Flair English sentiment model download - python

I'm trying to download the en-sentiment model using the following code:
clf = TextClassifier.load('en-sentiment')
but I'm getting the following SSL error:
SSLError: HTTPSConnectionPool(host='nlp.informatik.hu-berlin.de', port=443): Max retries exceeded with url: /resources/models/sentiment-curated-distilbert/sentiment-en-mix-distillbert_4.pt (Caused by SSLError(SSLError(1, '[SSL] unknown error (_ssl.c:1129)')))
I understand this is an issue with my firewall but I can't seem to get around it. I've tried installing openssl in my virtual env but this isn't working. I understand you can download the model manually but I can't find where to download them from.
Any help would be appreciated.

Max retries exceeded with url says it all. Are you sure you can ping the address: nlp.informatik.hu-berlin.de?
Are you sure you can access the resource with web browser?
https://nlp.informatik.hu-berlin.de/resources/models/sentiment-curated-distilbert/sentiment-en-mix-distillbert_4.pt
Please check if you are behind a proxy or firewall and if the certificate of the page is valid. Once you can access with web browser, you are going to be able to run your code.

Related

Python Integration the Payment System of Bank

I am trying to integrate the Bank's payment system on my Django-based website. As it said in documentation, I need to send parameters to their server (and then the new window should appear and the client should fill his card credentials there).
Documentation (part 1):
Documentation (part 2):
Documentation (part 3):
I am new in integration such services (payment) and need some help or broad explanation what to do, why do to that, and how.
Additionally, I was pretty sure that the following code wouldn't work fine but why.
import requests
def send_request():
url = 'https://ecomm.pashabank.az:18443/ecomm2/MerchantHandler/?command=v&amount=5&currency=932&client_ip_addr=167.184.1.132&msg_type=SMS'
response = requests.post(url)
print(response)
send_request()
causes
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='ecomm.pashabank.az', port=18443): Max retries exceeded with url: /ecomm2/MerchantHandler/?command=v&amount=5&currency=932&client_ip_addr=167.172.184.123&msg_type=SMS (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))
Overall, I need help of everything happening behind the scenes. Huge thanks in advance guys!
Note: I have also received some certifications from bank (I assume to assure the connection safety). But how I use it and when?

Python: request.get for github doesn't work

I am trying to run a GET request for a Github url. Unfortunately, I always get an error message.
I tried it for several different websites and it works, just not for github.
I am trying to do it with Jupyter Notebooks in Python, if that is important.
Here is the Error message:
ConnectionError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /jana-hoh/gdp/main/DP_LIVE_22102021141534889.csv (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f7a1c285d60>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
An error message that includes Temporary failure in name resolution indicates that the system's DNS server is unable to convert domain names into their corresponding IP address. Some of the causes are:
Your DNS configuration is correct, but the server is unable to respond to DNS requests at the moment
Firewall rules
No internet connectivity
Most of the times I've encountered this error stemmed from being disconnected to the internet. However, if your internet is working properly, you can try to add another DNS server in /etc/resolv.conf. For example, you can add cloudflare's:
nameserver 1.1.1.1

Pulling Mimecast Logs with Python

I am hoping someone has gone through this and hopefully has a working Python script. I have been trying to pull MTA logs from Mimecast. So far, I have tried the
codes from the below websites:
https://www.mimecast.com/tech-connect/documentation/endpoint-reference/logs-and-statistics/get-siem-logs/
https://github.com/JoshuaSmeda/mimecast_log_collector
https://github.com/bsdkid/mimecast-api-class/blob/master/get-TTP.py
The error I get is
SSLError: HTTPSConnectionPool(host='api.mimecast.com', port=443): Max retries exceeded with url: /api/login/discover-authentication (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),))
I also have all the necessary credentials, such as user(account), password, app_id, app_key, access_key, and secret_key. Unfortunately, nothing has worked for me.
Any help is much appreciated.
Thanks
You probably got some sort of SSL inspection happening in your environment.
Have you tried testing on a another test instance perhaps where there is no transparent proxy filtering internet traffic.
You can also try using the SSL verify argument (set to false) for the API request to ignore the cert validation issue.
Arg:
verify=False
Example based on https://github.com/JoshuaSmeda/mimecast_log_collector:
try:
r = requests.post(url='https://api.mimecast.com/api/login/discover-authentication', data=json.dumps(post_body), headers=headers, verify=False)
If it works for the discovery - then add the verify argument to each post. Keep in mind the risks of doing this because you open yourself up to MITM attacks as an example. The risks of HTTP would apply.
Documentation on requests can be found here:
https://buildmedia.readthedocs.org/media/pdf/requests/latest/requests.pdf
Hope this helps.

How to capture python https traffic in fiddler?

Python throws in errors when ever I try to do some data fetching task.
This only happens when I set fiddler to decrypt https traffic.
I have tried routing python traffic through 127.0.0.1:8888 and same with mozilla inorder to catch its traffic.
I also installed the certificate and trusted it via fiddler, I am not sure where I am going wrong.
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='google.com', port=443):
Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: CERTIFIC
ATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)'),))
This above is the error I get whenever I try to fetch a page with requests.
TL;DR The requests library does not use the windows certificate store, it has it's own one (as per https://bugs.python.org/issue28547). This means that your fiddler MITM certificate is not available to python requests by default.
Your options are
Disable SSL verification (verify=False)
Add your cert via the REQUESTS_CA_BUNDLE environment variable
Add your fiddler cert explicitly (verify='\path\to\cert')
More details can be found at http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification
On a side note, it does feel a little strange for requests to be using it's own cert bundle, rather than the platform supplied one - especially given all the browsers are happy to use the platform ones.
As pointed out by polhemic and Eric Aronesty, for testing purposes, you can set temporarily "CURL_CA_BUNDLE" to an empty string.
import os
os.environ['CURL_CA_BUNDLE'] = ''

Anaconda does not allow the creation of a new environment

I am just starting out with Anaconda, and trying to create a new environment. However, when I try to do this using the navigator, it giver the following error:
CondaHTTPError: HTTP None None for url <https://conda.anaconda.org/conda
forge/win-64/repodata.json><br>Elapsed: None<br><br>An HTTP error occurred
when trying to retrieve this URL.<br>HTTP errors are often intermittent,
and a simple retry will get you on your way.<br>ConnectionError
(MaxRetryError("HTTPSConnectionPool(host='conda.anaconda.org', port=443):
Max retries exceeded with url: /t/<TOKEN>/conda-forge/win-64/repodata.json
(Caused by NewConnectionError
('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at
0x0000000004C39080>: Failed to establish a new connection: [Errno 11004]
getaddrinfo failed',))",),)<br>
I have been reading a lot online and I think it has something to do with the .condarc file. However, I can't figure out how to solve this issue. Does anyone know how to fix this?
Many thanks in advance :)

Categories