I want to bring a Python package to an offline environment with pip --Qiita http://qiita.com/ryozi_tn/items/d08edf86dba5e7806da8
Python get-pip.py --download
did not workPython: Install the Python package in an environment that does not communicate with the Internet (revised) --CUBE SUGAR CONTAINER http://blog.amedama.jp/entry/2016/06/02/223808
Python get-pip.py wheel pip --no-cache-dir --download wheelhouse
will result in an errorBoth of them did not work well, so I will leave the result of trial and error. As an example, let's try the procedure to install django. A docker container was used to emulate a clean environment and an offline environment. In the actual environment, you can download and install without root privileges, and you can keep the system area such as / usr clean.
--The docker container is for emulating a clean environment.
--Allocate container host data area to container with -v
option
--I installed the pip command once.
-Although it is saved in / data / src, it can be saved anywhere as it is carried by USB memory etc. in the actual environment.
$ docker run -v `pwd`/django:/data --rm -i -t centos:centos7 /bin/bash
# useradd ym
# su - ym
//Up to this point for emulated environments
$ cd /data
$ curl -O https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py --user
$ pip download -d src pip setuptools wheel django
$ ll src/
-rw-rw-r-- 1 ym ym 6796229 Sep 17 16:00 Django-1.10.1-py2.py3-none-any.whl
-rw-rw-r-- 1 ym ym 1198961 Sep 17 15:59 pip-8.1.2-py2.py3-none-any.whl
-rw-rw-r-- 1 ym ym 465369 Sep 17 16:00 setuptools-27.2.0-py2.py3-none-any.whl
-rw-rw-r-- 1 ym ym 66878 Sep 17 16:00 wheel-0.29.0-py2.py3-none-any.whl
$ exit
# exit
--You can emulate an environment that is not connected to an external network at all by adding the --net none
option.
--In the real environment, copy the data downloaded from the USB memory.
$ docker run -v `pwd`/django:/data --net none --rm -i -t centos:centos7 /bin/bash
# useradd ym
# su - ym
//Up to this point for emulated environments
$ cd /data
$ python get-pip.py --no-index --find-links src --user
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ym/.local/bin:/home/ym/bin
$ pip -V
pip 8.1.2 from /home/ym/.local/lib/python2.7/site-packages (python 2.7)
$ pip install --no-index --find-links src --user django
$ python
Python 2.7.5 (default, Jun 24 2015, 00:41:19)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.10.1'
pip install --user <package>
Install to user's .localpip download — pip 8.1.2 documentation http://pip.readthedocs.io/en/stable/reference/pip_download/
pip install — pip 8.1.2 documentation http://pip.readthedocs.io/en/stable/reference/pip_install/
Find out which version of Python or Django you're using-Django Tips http://www.gesource.jp/programming/python/django/004.html
Recommended Posts