Python uses pip to install third-party libraries without an Internet connection, example for pg_activity

Step 1. Download dependencis and access internet

$ pip download pg_activity -d ~/Downloads
Collecting pg_activity
  Downloading pg_activity-3.4.2-py3-none-any.whl.metadata (13 kB)
Collecting attrs!=21.1,>=17.4 (from pg_activity)
  Downloading attrs-23.2.0-py3-none-any.whl.metadata (9.5 kB)
Collecting blessed>=1.15.0 (from pg_activity)
  Downloading blessed-1.20.0-py2.py3-none-any.whl (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.4/58.4 kB 547.9 kB/s eta 0:00:00
Collecting humanize>=0.5.1 (from pg_activity)
  Downloading humanize-4.9.0-py3-none-any.whl.metadata (7.9 kB)
Collecting psutil>=2.0.0 (from pg_activity)
  Downloading psutil-5.9.7-cp36-abi3-macosx_10_9_x86_64.whl.metadata (21 kB)
Collecting wcwidth>=0.1.4 (from blessed>=1.15.0->pg_activity)
  Downloading wcwidth-0.2.12-py2.py3-none-any.whl.metadata (14 kB)
Collecting six>=1.9.0 (from blessed>=1.15.0->pg_activity)
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Downloading pg_activity-3.4.2-py3-none-any.whl (67 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 68.0/68.0 kB 1.1 MB/s eta 0:00:00
Downloading attrs-23.2.0-py3-none-any.whl (60 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.8/60.8 kB 1.3 MB/s eta 0:00:00
Downloading humanize-4.9.0-py3-none-any.whl (126 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 126.8/126.8 kB 2.0 MB/s eta 0:00:00
Downloading psutil-5.9.7-cp36-abi3-macosx_10_9_x86_64.whl (245 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 246.0/246.0 kB 3.9 MB/s eta 0:00:00
Downloading wcwidth-0.2.12-py2.py3-none-any.whl (34 kB)
Saved ./pg_activity-3.4.2-py3-none-any.whl
Saved ./attrs-23.2.0-py3-none-any.whl
Saved ./blessed-1.20.0-py2.py3-none-any.whl
Saved ./humanize-4.9.0-py3-none-any.whl
Saved ./psutil-5.9.7-cp36-abi3-macosx_10_9_x86_64.whl
Saved ./six-1.16.0-py2.py3-none-any.whl
Saved ./wcwidth-0.2.12-py2.py3-none-any.whl
Successfully downloaded pg_activity attrs blessed humanize psutil six wcwidth

Step 2. Copy Download files to no internet machine

$scp ~/Downloads/*.whl user@remote_ipaddress:~/pg_activity

Step 3. Install third party using pip on venv

$ cd pg_activity
$ python3 -m venv .venv
$ . .venv/bin/activate

Shell command

(.venv) $ cat install.sh

#!/usr/bin/python3.11

pip install attrs-23.1.0-py3-none-any.whl
pip install six-1.16.0-py2.py3-none-any.whl
pip install wcwidth-0.2.12-py2.py3-none-any.whl
pip install blessed-1.20.0-py2.py3-none-any.whl
pip install humanize-4.9.0-py3-none-any.whl
pip install setuptools-69.0.3-py3-none-any.whl
pip install typing_extensions-4.9.0-py3-none-any.whl
pip install psycopg-3.1.16-py3-none-any.whl
pip install psutil-5.9.7-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip install pg_activity-3.4.2-py3-none-any.whl


(.venv) $ sh install.sh

Ref:

installing python packages without internet and using source code as .tar.gz and .whl

張貼留言

0 留言