Cannot close the proxy
In windows pycharm jupyterlab when i open windows system proxy requests will use the proxy i set on windows system. but cannot close this proxy direct to the internet . I try
response = requests.post(url, headers=headers, json=data, proxies=None)
response = requests.post(url, headers=headers, json=data, proxies={})
response = requests.post(url, headers=headers, json=data, proxies="")
can't work
Expected Result
don't use proxy I set on windows
Actual Result
I can check this connection on clash
Reproduction Steps
windows requests 2.31.0 use pycharm and jupyter
import requests
response = requests.post(url, headers=headers, json=data, proxies=None)# I try None {} "" []
System Information
$ python -m requests.help
{
"chardet": {
"version": null
},
"charset_normalizer": {
"version": "2.0.4"
},
"cryptography": {
"version": "41.0.7"
},
"idna": {
"version": "3.4"
},
"implementation": {
"name": "CPython",
"version": "3.11.5"
},
"platform": {
"release": "10",
"system": "Windows"
},
"pyOpenSSL": {
"openssl_version": "300000c0",
"version": "23.2.0"
},
"requests": {
"version": "2.31.0"
},
"system_ssl": {
"version": "300000c0"
},
"urllib3": {
"version": "1.26.18"
},
"using_charset_normalizer": true,
"using_pyopenssl": true
}
``The issue here is that on Windows, requests respects system-wide proxy settings by default when making HTTP requests. If you want to bypass these proxies and make requests directly to the internet, setting proxies=None, {}, or an empty string "" does not work because requests will still attempt to use the system proxy configuration.
>
>
> `import requests
>
> response = requests.post(
> url,
> headers=headers,
> json=data,
> proxies={"http": None, "https": None} # Disable proxies explicitly
> )
>
> print(response.status_code)
> print(response.text)
Setting proxies={"http": None, "https": None} tells requests not to use any proxies for both HTTP and HTTPS requests.
If you’re making multiple calls, use a session:
import requests
session = requests.Session() session.trust_env = False # <- disables using system proxy
response = session.post(url, headers=headers, json=data)