How to install pip pacakges offline?
by aaronchenwei
If you want install python libs and their dependencies offline, finish following these steps on a machine with the same CPU architecture, OS, network connected, and python installed:
On the system that has access to internet
-
Create a
requirements.txtfile with similar content (Note - these are the libraries you wish to download):Flask==0.12 requests>=2.7.0 scikit-learn==0.19.1 numpy==1.14.3 pandas==0.22.0One option for creating the requirements file is to use
pip freeze > requirements.txt. This will list all libraries in your environment. Then you can go in torequirements.txtand remove un-needed ones. -
Execute following command to download libs and their dependencies to directory
wheelhouse.$ mkdir wheelhouse $ pip download -r requirements.txt -d wheelhouse -
Copy
requirements.txtintowheelhousedirectory. -
Archive wheelhouse into
wheelhouse.tar.gzwith commandtar -zcf wheelhouse.tar.gz wheelhouse. Then uploadwheelhouse.tar.gzto your target machine.
On the system that has no access to internet
-
Execute
tar -zxf wheelhouse.tar.gzto extract the files. -
Execute
pip install -r wheelhouse/requirements.txt --no-index --find-links wheelhouseto install the libs and their dependencies