Linux system first exports environment variables like this
$ export http_proxy="http://<user>:<pass>@<proxy>:<port>" $ export HTTP_PROXY="http://<user>:<pass>@<proxy>:<port>" $ export https_proxy="http://<user>:<pass>@<proxy>:<port>" $ export HTTPS_PROXY="http://<user>:<pass>@<proxy>:<port>"
or in the script you want to go through the proxy
import os proxy = 'http://<user>:<pass>@<proxy>:<port>' os.environ['http_proxy'] = proxy os.environ['HTTP_PROXY'] = proxy os.environ['https_proxy'] = proxy os.environ['HTTPS_PROXY'] = proxy
then run the python script
$ python my_script.py
UPDATE
You can also use redsocks with this tool, you can silently redirect all your TCP connections to PROXY with or without authentication. But you have to take care, because this is for all compounds, not just python.
Windows systems , you can use tools such as FreeCap , Proxifier , ProxyCap and configure to work with python executable
source share