Quantcast
Channel: Howtos & more …– LANbugs
Viewing all articles
Browse latest Browse all 144

pip offline verwenden

$
0
0

Wenn man ein System hat das isoliert ist, z.B. in einer DMZ und keinen Internetzugriff hat man aber trotzdem für python Pakete per pip installieren will kann man diese auf einem anderen System herunterladen mit allen Abhängigkeiten und diese dann im Zielsystem installieren. Quell und Zielsystem sollten die gleiche Python Version haben.

Download z.B. von Ansible

Mit „pip3 download ansible“ wird das Ansible Packet und alle Abhänigkeiten in den aktuellen Ordner geladen.

# mkdir ansible
# cd ansible/
# pip3 download ansible
Collecting ansible
  Downloading ansible-2.10.4.tar.gz (28.6 MB)
     |████████████████████████████████| 28.6 MB 1.3 MB/s
  Saved ./ansible-2.10.4.tar.gz
Collecting ansible-base<2.11,>=2.10.3
  Downloading ansible-base-2.10.4.tar.gz (5.7 MB)
     |████████████████████████████████| 5.7 MB 26.4 MB/s
  Saved ./ansible-base-2.10.4.tar.gz
Collecting PyYAML
  Downloading PyYAML-5.3.1.tar.gz (269 kB)
     |████████████████████████████████| 269 kB 10.4 MB/s
  Saved ./PyYAML-5.3.1.tar.gz
Collecting cryptography
  Downloading cryptography-3.3.1-cp36-abi3-manylinux2010_x86_64.whl (2.6 MB)
     |████████████████████████████████| 2.6 MB 33.9 MB/s
  Saved ./cryptography-3.3.1-cp36-abi3-manylinux2010_x86_64.whl
Collecting jinja2
  Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 43.3 MB/s
  Saved ./Jinja2-2.11.2-py2.py3-none-any.whl
Collecting packaging
  Downloading packaging-20.8-py2.py3-none-any.whl (39 kB)
  Saved ./packaging-20.8-py2.py3-none-any.whl
Collecting six>=1.4.1
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
  Saved ./six-1.15.0-py2.py3-none-any.whl
Collecting cffi>=1.12
  Downloading cffi-1.14.4-cp38-cp38-manylinux1_x86_64.whl (411 kB)
     |████████████████████████████████| 411 kB 50.1 MB/s
  Saved ./cffi-1.14.4-cp38-cp38-manylinux1_x86_64.whl
Collecting MarkupSafe>=0.23
  Downloading MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl (32 kB)
  Saved ./MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl
Collecting pyparsing>=2.0.2
  Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
     |████████████████████████████████| 67 kB 7.7 MB/s
  Saved ./pyparsing-2.4.7-py2.py3-none-any.whl
Collecting pycparser
  Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
     |████████████████████████████████| 112 kB 36.9 MB/s
  Saved ./pycparser-2.20-py2.py3-none-any.whl
Successfully downloaded ansible ansible-base PyYAML cryptography jinja2 packaging six cffi MarkupSafe pyparsing pycparser

# ll
total 37148
drwxr-xr-x 2 root   root       4096 Dec 22 20:38 ./
drwxr-xr-x 8 sysusr sysusr     4096 Dec 22 20:37 ../
-rw-r--r-- 1 root   root   28622006 Dec 22 20:38 ansible-2.10.4.tar.gz
-rw-r--r-- 1 root   root    5708083 Dec 22 20:38 ansible-base-2.10.4.tar.gz
-rw-r--r-- 1 root   root     411052 Dec 22 20:38 cffi-1.14.4-cp38-cp38-manylinux1_x86_64.whl
-rw-r--r-- 1 root   root    2617057 Dec 22 20:38 cryptography-3.3.1-cp36-abi3-manylinux2010_x86_64.whl
-rw-r--r-- 1 root   root     125774 Dec 22 20:38 Jinja2-2.11.2-py2.py3-none-any.whl
-rw-r--r-- 1 root   root      32690 Dec 22 20:38 MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl
-rw-r--r-- 1 root   root      39857 Dec 22 20:38 packaging-20.8-py2.py3-none-any.whl
-rw-r--r-- 1 root   root     112041 Dec 22 20:38 pycparser-2.20-py2.py3-none-any.whl
-rw-r--r-- 1 root   root      67842 Dec 22 20:38 pyparsing-2.4.7-py2.py3-none-any.whl
-rw-r--r-- 1 root   root     269377 Dec 22 20:38 PyYAML-5.3.1.tar.gz
-rw-r--r-- 1 root   root      10963 Dec 22 20:38 six-1.15.0-py2.py3-none-any.whl

Die Dateien im Ordner ansible auf das Zielsystem kopieren:

Installation mit Abhänigkeiten aus einem Ordner

Mit folgendem Befehl lässt sich die Installation durchführen:

ansible # pip3 install –no-index –find-links=./ ansible

Beispiel:

# cd ansible
ansible # pip3 install --no-index --find-links=./ ansible
Looking in links: ./
Processing ./ansible-2.10.4.tar.gz
Processing ./ansible-base-2.10.4.tar.gz
Processing ./PyYAML-5.3.1.tar.gz
Processing ./cryptography-3.3.1-cp36-abi3-manylinux2010_x86_64.whl
Processing ./Jinja2-2.11.2-py2.py3-none-any.whl
Processing ./packaging-20.8-py2.py3-none-any.whl
Processing ./cffi-1.14.4-cp38-cp38-manylinux1_x86_64.whl
Processing ./six-1.15.0-py2.py3-none-any.whl
Processing ./MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl
Processing ./pyparsing-2.4.7-py2.py3-none-any.whl
Processing ./pycparser-2.20-py2.py3-none-any.whl
Building wheels for collected packages: ansible, ansible-base, PyYAML
  Building wheel for ansible (setup.py) ... done
  Created wheel for ansible: filename=ansible-2.10.4-py3-none-any.whl size=47089993 sha256=89e63c24fc6f3ba669bce6b0692707bf10f0ef7734f116cc5125d03a18d7f8c8
  Stored in directory: /home/sysusr/.cache/pip/wheels/78/ce/b9/59612ba2607a232765439606725eb7f4efa45ad74d7608e120
  Building wheel for ansible-base (setup.py) ... done
  Created wheel for ansible-base: filename=ansible_base-2.10.4-py3-none-any.whl size=1868521 sha256=845b55c9da98828026dea1a0203a1a39dffd01c2ec25c55dd5958c21ab8e67c2
  Stored in directory: /home/sysusr/.cache/pip/wheels/5e/b2/04/1f3fec9739561b3c829f3b7c9d99517f7695d82dc4bd898570
  Building wheel for PyYAML (setup.py) ... done
  Created wheel for PyYAML: filename=PyYAML-5.3.1-cp38-cp38-linux_x86_64.whl size=44618 sha256=f27189ef8eca29389925c49556d1f829a2e257e6728a00043bb82e24e1f03cee
  Stored in directory: /home/sysusr/.cache/pip/wheels/23/63/23/58d84df6fa809eb1faea3cef1c79d73e276e7a2881ea1ac873
Successfully built ansible ansible-base PyYAML
Installing collected packages: PyYAML, pycparser, cffi, six, cryptography, MarkupSafe, jinja2, pyparsing, packaging, ansible-base, ansible
Successfully installed MarkupSafe-1.1.1 PyYAML-5.3.1 ansible-2.10.4 ansible-base-2.10.4 cffi-1.14.4 cryptography-3.3.1 jinja2-2.11.2 packaging-20.8 pycparser-2.20 pyparsing-2.4.7 six-1.15.0

Viewing all articles
Browse latest Browse all 144