{"id":5485,"date":"2019-07-02T10:10:23","date_gmt":"2019-07-02T15:10:23","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5485"},"modified":"2020-05-21T09:17:41","modified_gmt":"2020-05-21T14:17:41","slug":"two-approaches-to-using-pip-through-an-integrated-authenticated-proxy","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5485","title":{"rendered":"Two Approaches to Using PIP Through an Integrated Authenticated Proxy"},"content":{"rendered":"<p>The proxy at work uses integrated authentication. While BASIC auth prompts happily let you use a proxy of http:\/\/uid:pass@proxy:port, ours does not. There are two ways I&#8217;ve managed to use pip to install packages.<\/p>\n<p><em><strong>Proxied Proxy<\/strong><\/em><\/p>\n<p>The easiest approach is to use something that can handle the authenticated proxy, like Fiddler, as an intermediary. I do the same thing with <a href=\"https:\/\/www.rushworth.us\/lisa\/?p=1635\">perl&#8217;s PPM<\/a>, docker pull &#8230; basically anywhere I&#8217;ve got to use a proxy that wants to pass through a proxy username.<\/p>\n<p>Select Tools =&gt; Options to open the configuration dialog. Make sure you are handling SSL traffic &#8212; if not, check the box to &#8220;Capture HTTPS CONNECTs, &#8220;Decrypt HTTPS traffic&#8221;, and &#8220;Ignore server certificate errors&#8221; (it&#8217;s only unsafe if you don&#8217;t understand what you&#8217;re doing &#8230; don&#8217;t log into your bank account bouncing traffic through this config!)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"460\" class=\"wp-image-5486\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image.png 678w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-300x204.png 300w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/p>\n<p>On the &#8220;Connections&#8221; tab, check the port on which Fiddler is listening. If you cannot install Fiddler on the same box where you want to use pip, you&#8217;ll need to check off &#8220;Allow remote computers to connect&#8221; (and you won&#8217;t use localhost as the proxy hostname). Click OK, start capturing traffic (F12), and we&#8217;re ready to go.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"460\" class=\"wp-image-5487\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-1.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-1.png 678w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-1-300x204.png 300w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/p>\n<p>Use the PIP command line to install the package <em>but<\/em> proxy the request through your Fiddler instance. In this example, Fiddler is installed on the local box and uses port 8888.<\/p>\n<p><strong>pip &#8211;trusted-host pypi.org &#8211;trusted-host files.pythonhosted.org &#8211;proxy http:\/\/localhost:8888 install SomePackage<\/strong><\/p>\n<p>This is nice because pip will automatically resolve dependencies. Not great if you&#8217;re not allowed to install your own software and cannot get Fiddler installed.<\/p>\n<p><strong><em>Dependency <\/em><em>Nighmare<\/em><\/strong><\/p>\n<p>Back in the early days of Linux (think waaaay before package managers working against online repositories), we called this &#8220;dependency hell&#8221; &#8212; navigating dependency chains to get all of the required &#8220;stuff&#8221; on the box so you can install the thing you actually wanted.<\/p>\n<p>Make a folder for all these wheels we&#8217;re going to end up downloading so it&#8217;s easy to clean up once we&#8217;re done. Search PyPi for the package you want. On the package page, select &#8216;Download Files&#8217; and then download the whl<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1913\" height=\"863\" class=\"wp-image-5488\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-2.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-2.png 1913w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-2-300x135.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-2-768x346.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/07\/word-image-2-1024x462.png 1024w\" sizes=\"auto, (max-width: 1913px) 100vw, 1913px\" \/><\/p>\n<p>Use &#8220;pip install something.whl&#8221; to attempt installing it. If you&#8217;re lucky, you&#8217;ve got all the dependencies and the package will install. If you don&#8217;t have all of the dependencies, you&#8217;ll get an error telling you the first missing one. Go back to the pypi website &amp; get that. Use &#8220;pip install somethingelse.whl&#8221; to install it and maybe get a dependency error here too. Once you get a dependency installed, try the package you want again. Got another error? Start downloading and installing again. Eventually, though, you&#8217;ll get all of the dependencies satisfied and be able to install the package you actually want.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The proxy at work uses integrated authentication. While BASIC auth prompts happily let you use a proxy of http:\/\/uid:pass@proxy:port, ours does not. There are two ways I&#8217;ve managed to use pip to install packages. Proxied Proxy The easiest approach is to use something that can handle the authenticated proxy, like Fiddler, as an intermediary. I &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,30],"tags":[344,752,664],"class_list":["post-5485","post","type-post","status-publish","format-standard","hentry","category-coding","category-system-administration","tag-fiddler","tag-pip","tag-python"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5485"}],"version-history":[{"count":5,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5485\/revisions"}],"predecessor-version":[{"id":6469,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5485\/revisions\/6469"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}