How to set the proxy settings in Windows via command line
Once in a while I need to download and install Python packages at work and having switched to Linux (Ubuntu) at home, I find it quite annoying now to have to go to a website, download the package I need, then manually install.
Fortunately, the pip installer works for Windows as well, allowing the installation of Python packages automatically with a simple command (pip install package_name). But at work, we’re behind a proxy server so I have to set the HTTP_PROXY environment variable first before pip can connect to download the packages.
You can set this environment variable permanently so you don’t have to keep re-typing it every time you open a cmd window, but since our proxy requires authentication I prefer not to hardcode it (plus I’ll have to remember to update when my password changes).
Simply type this in the cmd window to set it (note that the setting will get deleted once you close the window):
set HTTP_PROXY=http://user:password@proxy.domain.com:port