Forked from prateek/python-package-offline-install-notes.md
Created
September 8, 2018 15:30
-
-
Save worldwidenow/cf7b48dfa0e5479fe8087818b937313d to your computer and use it in GitHub Desktop.
Revisions
-
prateek renamed this gist
Mar 17, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
prateek revised this gist
Mar 17, 2015 . No changes.There are no files selected for viewing
-
prateek created this gist
Mar 17, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ Offline Python Package Install Notes ==================================== Two common cases which make the install of Python packages harder due to networking issues are: a) Install behind a Proxy b) Install without access to the internet ## (a) Install behind a Proxy In the case where the target machine connects to the internet over a network proxy, export the following environment vars, as appropriate - `http_proxy` and `https_proxy`. Eg: ```sh $ export https_proxy=http://proxy.mydomain.com:<port> $ export http_proxy=http://proxy.mydomain.com:<port> $ pip install <package> ``` ## (b) Install without access to the internet In the case where the target machine does not have connectivity to the internet, you have to download the package and dependencies using a machine which does have connectivity to the internet. After which the install can follow. Sample instructions - ### Step 1. Download Packages for Offline Install Execute the instructions below download the packages on a machine which is able to connect to the internet. ```sh # if a single package is being installed $ pip install <package> --download /tmp/offline_packages # or, if a list of dependencies are to be installed $ pip install --download /tmp/offline_packages -r requirements.txt ``` ### Step 2. Transfer downloaded packages Transfer downloaded packages to the target machine where the install is to be performed. Use scp/sftp/etc. ### Step 3. Install packages Assuming the directory `/tmp/transferred_packages` contains the contents of `/tmp/offline_packages` from the earlier machine, execute the following steps on the the target machine. ```sh # if a single package is being installed $ pip install --no-index --find-links="/tmp/tranferred_packages" <package> # if a list of dependencies are to be installed $ pip install --no-index --find-links="/tmp/tranferred_packages" -r requirements.txt ``` ---------- ### References [1]: http://stackoverflow.com/questions/7300321/how-to-use-pythons-pip-to-download-and-keep-the-zipped-files-for-a-package