티스토리 뷰

728x90
반응형

본 포스팅에서는 python package install 방법에 대해 알아보겠습니다.

기본적으로 python package는 pip라는 package manager를 이용하여 손쉽게 관리될 수 있습니다.

다만 인터넷이 안되는 폐쇄망이거나, SSL, 방화벽 등의 이유로 pip를 사용할 수 없을 경우 설치 방법에 대해 알아보겠습니다.

pip package manager를 사용하지 않고 수동으로 설치하기 위해서는 직접 python package를 다운로드 받아야합니다.

예를 들어 ansible-playbook을 실행하기 위한 jinja2를 설치하는 과정을 직접 진행해 보도록 하겠습니다.

 

1. python package site download

먼저 다음 URL에서 설치하기 원하는 python package를 다운로드 받습니다.

URL : https://pypi.org/

 

PyPI · The Python Package Index

The Python Package Index (PyPI) is a repository of software for the Python programming language.

pypi.org

위와 같이 해당 사이트에서 jinja2를 검색하여 원하는 소스 버전의 파일을 다운로드 받아 설치하고자 하는 서버에 업로드합니다.

물론 URL을 알고 있을 경우 다음과 같은 방식으로도 직접 접근이 가능합니다.

 

2. 압축해제 및 현재 설치된 버전 확인

업로드한 파일을 압축을 해제하고 현재 설치된 버전을 확인합니다.

[root@kubemaster ~]# tar -xzvf Jinja2-2.10.3.tar.gz 
Jinja2-2.10.3/
Jinja2-2.10.3/CHANGES.rst
Jinja2-2.10.3/Jinja2.egg-info/
Jinja2-2.10.3/Jinja2.egg-info/PKG-INFO
Jinja2-2.10.3/Jinja2.egg-info/SOURCES.txt
Jinja2-2.10.3/Jinja2.egg-info/dependency_links.txt
Jinja2-2.10.3/Jinja2.egg-info/entry_points.txt
Jinja2-2.10.3/Jinja2.egg-info/requires.txt
Jinja2-2.10.3/Jinja2.egg-info/top_level.txt
Jinja2-2.10.3/LICENSE.rst
Jinja2-2.10.3/MANIFEST.in
Jinja2-2.10.3/PKG-INFO
Jinja2-2.10.3/README.rst
Jinja2-2.10.3/artwork/
Jinja2-2.10.3/artwork/jinjalogo.svg
Jinja2-2.10.3/docs/
Jinja2-2.10.3/docs/Makefile
Jinja2-2.10.3/docs/_static/
Jinja2-2.10.3/docs/_static/jinja-logo-sidebar.png
Jinja2-2.10.3/docs/_static/jinja-logo.png
Jinja2-2.10.3/docs/api.rst
Jinja2-2.10.3/docs/cache_extension.py
Jinja2-2.10.3/docs/changelog.rst
Jinja2-2.10.3/docs/conf.py
Jinja2-2.10.3/docs/extensions.rst
Jinja2-2.10.3/docs/faq.rst
Jinja2-2.10.3/docs/index.rst
Jinja2-2.10.3/docs/integration.rst
Jinja2-2.10.3/docs/intro.rst
Jinja2-2.10.3/docs/make.bat
Jinja2-2.10.3/docs/nativetypes.rst
Jinja2-2.10.3/docs/requirements.txt
Jinja2-2.10.3/docs/sandbox.rst
Jinja2-2.10.3/docs/switching.rst
Jinja2-2.10.3/docs/templates.rst
Jinja2-2.10.3/docs/tricks.rst
Jinja2-2.10.3/examples/
Jinja2-2.10.3/examples/basic/
Jinja2-2.10.3/examples/basic/cycle.py
Jinja2-2.10.3/examples/basic/debugger.py
Jinja2-2.10.3/examples/basic/inheritance.py
Jinja2-2.10.3/examples/basic/templates/
Jinja2-2.10.3/examples/basic/templates/broken.html
Jinja2-2.10.3/examples/basic/templates/subbroken.html
Jinja2-2.10.3/examples/basic/test.py
Jinja2-2.10.3/examples/basic/test_filter_and_linestatements.py
Jinja2-2.10.3/examples/basic/test_loop_filter.py
Jinja2-2.10.3/examples/basic/translate.py
Jinja2-2.10.3/examples/bench.py
Jinja2-2.10.3/examples/profile.py
Jinja2-2.10.3/examples/rwbench/
Jinja2-2.10.3/examples/rwbench/django/
Jinja2-2.10.3/examples/rwbench/django/_form.html
Jinja2-2.10.3/examples/rwbench/django/_input_field.html
Jinja2-2.10.3/examples/rwbench/django/_textarea.html
Jinja2-2.10.3/examples/rwbench/django/index.html
Jinja2-2.10.3/examples/rwbench/django/layout.html
Jinja2-2.10.3/examples/rwbench/djangoext.py
Jinja2-2.10.3/examples/rwbench/genshi/
Jinja2-2.10.3/examples/rwbench/genshi/helpers.html
Jinja2-2.10.3/examples/rwbench/genshi/index.html
Jinja2-2.10.3/examples/rwbench/genshi/layout.html
Jinja2-2.10.3/examples/rwbench/jinja/
Jinja2-2.10.3/examples/rwbench/jinja/helpers.html
Jinja2-2.10.3/examples/rwbench/jinja/index.html
Jinja2-2.10.3/examples/rwbench/jinja/layout.html
Jinja2-2.10.3/examples/rwbench/mako/
Jinja2-2.10.3/examples/rwbench/mako/helpers.html
Jinja2-2.10.3/examples/rwbench/mako/index.html
Jinja2-2.10.3/examples/rwbench/mako/layout.html
Jinja2-2.10.3/examples/rwbench/rwbench.py
Jinja2-2.10.3/ext/
Jinja2-2.10.3/ext/Vim/
Jinja2-2.10.3/ext/Vim/jinja.vim
Jinja2-2.10.3/ext/django2jinja/
Jinja2-2.10.3/ext/django2jinja/django2jinja.py
Jinja2-2.10.3/ext/django2jinja/example.py
Jinja2-2.10.3/ext/django2jinja/templates/
Jinja2-2.10.3/ext/django2jinja/templates/index.html
Jinja2-2.10.3/ext/django2jinja/templates/layout.html
Jinja2-2.10.3/ext/django2jinja/templates/subtemplate.html
Jinja2-2.10.3/ext/djangojinja2.py
Jinja2-2.10.3/ext/inlinegettext.py
Jinja2-2.10.3/ext/jinja.el
Jinja2-2.10.3/jinja2/
Jinja2-2.10.3/jinja2/__init__.py
Jinja2-2.10.3/jinja2/_compat.py
Jinja2-2.10.3/jinja2/_identifier.py
Jinja2-2.10.3/jinja2/asyncfilters.py
Jinja2-2.10.3/jinja2/asyncsupport.py
Jinja2-2.10.3/jinja2/bccache.py
Jinja2-2.10.3/jinja2/compiler.py
Jinja2-2.10.3/jinja2/constants.py
Jinja2-2.10.3/jinja2/debug.py
Jinja2-2.10.3/jinja2/defaults.py
Jinja2-2.10.3/jinja2/environment.py
Jinja2-2.10.3/jinja2/exceptions.py
Jinja2-2.10.3/jinja2/ext.py
Jinja2-2.10.3/jinja2/filters.py
Jinja2-2.10.3/jinja2/idtracking.py
Jinja2-2.10.3/jinja2/lexer.py
Jinja2-2.10.3/jinja2/loaders.py
Jinja2-2.10.3/jinja2/meta.py
Jinja2-2.10.3/jinja2/nativetypes.py
Jinja2-2.10.3/jinja2/nodes.py
Jinja2-2.10.3/jinja2/optimizer.py
Jinja2-2.10.3/jinja2/parser.py
Jinja2-2.10.3/jinja2/runtime.py
Jinja2-2.10.3/jinja2/sandbox.py
Jinja2-2.10.3/jinja2/tests.py
Jinja2-2.10.3/jinja2/utils.py
Jinja2-2.10.3/jinja2/visitor.py
Jinja2-2.10.3/setup.cfg
Jinja2-2.10.3/setup.py
Jinja2-2.10.3/tests/
Jinja2-2.10.3/tests/conftest.py
Jinja2-2.10.3/tests/res/
Jinja2-2.10.3/tests/res/__init__.py
Jinja2-2.10.3/tests/res/templates/
Jinja2-2.10.3/tests/res/templates/broken.html
Jinja2-2.10.3/tests/res/templates/foo/
Jinja2-2.10.3/tests/res/templates/foo/test.html
Jinja2-2.10.3/tests/res/templates/syntaxerror.html
Jinja2-2.10.3/tests/res/templates/test.html
Jinja2-2.10.3/tests/test_api.py
Jinja2-2.10.3/tests/test_async.py
Jinja2-2.10.3/tests/test_asyncfilters.py
Jinja2-2.10.3/tests/test_bytecode_cache.py
Jinja2-2.10.3/tests/test_core_tags.py
Jinja2-2.10.3/tests/test_debug.py
Jinja2-2.10.3/tests/test_ext.py
Jinja2-2.10.3/tests/test_features.py
Jinja2-2.10.3/tests/test_filters.py
Jinja2-2.10.3/tests/test_idtracking.py
Jinja2-2.10.3/tests/test_imports.py
Jinja2-2.10.3/tests/test_inheritance.py
Jinja2-2.10.3/tests/test_lexnparse.py
Jinja2-2.10.3/tests/test_loader.py
Jinja2-2.10.3/tests/test_nativetypes.py
Jinja2-2.10.3/tests/test_regression.py
Jinja2-2.10.3/tests/test_security.py
Jinja2-2.10.3/tests/test_tests.py
Jinja2-2.10.3/tests/test_utils.py
Jinja2-2.10.3/tox.ini
[root@kubemaster ~]# pip3 show jinja2
[root@kubemaster ~]#

위와 같이 현재 jinja2는 설치되어 있지 않습니다.

 

3. jinja2 python 명령어로 설치

[root@kubemaster Jinja2-2.10.3]# ls -la
total 68
drwxr-xr-x.  9 kubemaster kubemaster   249 Oct  5 03:50 .
dr-xr-x---. 18 root       root        4096 Oct 13 22:38 ..
drwxr-xr-x.  2 kubemaster kubemaster    27 Oct  5 03:50 artwork
-rw-r--r--.  1 kubemaster kubemaster 24274 Oct  5 03:49 CHANGES.rst
drwxr-xr-x.  3 kubemaster kubemaster  4096 Oct  5 03:50 docs
drwxr-xr-x.  4 kubemaster kubemaster    68 Oct  5 03:50 examples
drwxr-xr-x.  4 kubemaster kubemaster   100 Oct  5 03:50 ext
drwxr-xr-x.  2 kubemaster kubemaster  4096 Oct  5 03:50 jinja2
drwxr-xr-x.  2 kubemaster kubemaster   134 Oct  5 03:50 Jinja2.egg-info
-rw-r--r--.  1 kubemaster kubemaster  1475 Oct  5 03:36 LICENSE.rst
-rw-r--r--.  1 kubemaster kubemaster   108 Oct  5 03:36 MANIFEST.in
-rw-r--r--.  1 kubemaster kubemaster  3837 Oct  5 03:50 PKG-INFO
-rw-r--r--.  1 kubemaster kubemaster  1858 Oct  5 03:36 README.rst
-rw-r--r--.  1 kubemaster kubemaster   307 Oct  5 03:50 setup.cfg
-rw-r--r--.  1 kubemaster kubemaster  2039 Oct  5 03:47 setup.py
drwxr-xr-x.  3 kubemaster kubemaster  4096 Oct  5 03:50 tests
-rw-r--r--.  1 kubemaster kubemaster   756 Oct  5 03:36 tox.ini
[root@kubemaster Jinja2-2.10.3]# python3 setup.py install
running install
running bdist_egg
running egg_info
writing Jinja2.egg-info/PKG-INFO
writing dependency_links to Jinja2.egg-info/dependency_links.txt
writing entry points to Jinja2.egg-info/entry_points.txt
writing requirements to Jinja2.egg-info/requires.txt
writing top-level names to Jinja2.egg-info/top_level.txt
reading manifest file 'Jinja2.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
writing manifest file 'Jinja2.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/jinja2
copying jinja2/__init__.py -> build/lib/jinja2
copying jinja2/_compat.py -> build/lib/jinja2
copying jinja2/_identifier.py -> build/lib/jinja2
copying jinja2/asyncfilters.py -> build/lib/jinja2
copying jinja2/asyncsupport.py -> build/lib/jinja2
copying jinja2/bccache.py -> build/lib/jinja2
copying jinja2/compiler.py -> build/lib/jinja2
copying jinja2/constants.py -> build/lib/jinja2
copying jinja2/debug.py -> build/lib/jinja2
copying jinja2/defaults.py -> build/lib/jinja2
copying jinja2/environment.py -> build/lib/jinja2
copying jinja2/exceptions.py -> build/lib/jinja2
copying jinja2/ext.py -> build/lib/jinja2
copying jinja2/filters.py -> build/lib/jinja2
copying jinja2/idtracking.py -> build/lib/jinja2
copying jinja2/lexer.py -> build/lib/jinja2
copying jinja2/loaders.py -> build/lib/jinja2
copying jinja2/meta.py -> build/lib/jinja2
copying jinja2/nativetypes.py -> build/lib/jinja2
copying jinja2/nodes.py -> build/lib/jinja2
copying jinja2/optimizer.py -> build/lib/jinja2
copying jinja2/parser.py -> build/lib/jinja2
copying jinja2/runtime.py -> build/lib/jinja2
copying jinja2/sandbox.py -> build/lib/jinja2
copying jinja2/tests.py -> build/lib/jinja2
copying jinja2/utils.py -> build/lib/jinja2
copying jinja2/visitor.py -> build/lib/jinja2
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/__init__.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/_compat.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/_identifier.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/asyncfilters.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/asyncsupport.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/bccache.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/compiler.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/constants.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/debug.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/defaults.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/environment.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/exceptions.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/ext.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/filters.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/idtracking.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/lexer.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/loaders.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/meta.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/nativetypes.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/nodes.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/optimizer.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/parser.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/runtime.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/sandbox.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/tests.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/utils.py -> build/bdist.linux-x86_64/egg/jinja2
copying build/lib/jinja2/visitor.py -> build/bdist.linux-x86_64/egg/jinja2
byte-compiling build/bdist.linux-x86_64/egg/jinja2/__init__.py to __init__.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/_compat.py to _compat.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/_identifier.py to _identifier.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/asyncfilters.py to asyncfilters.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/asyncsupport.py to asyncsupport.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/bccache.py to bccache.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/compiler.py to compiler.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/constants.py to constants.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/debug.py to debug.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/defaults.py to defaults.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/environment.py to environment.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/exceptions.py to exceptions.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/ext.py to ext.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/filters.py to filters.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/idtracking.py to idtracking.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/lexer.py to lexer.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/loaders.py to loaders.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/meta.py to meta.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/nativetypes.py to nativetypes.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/nodes.py to nodes.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/optimizer.py to optimizer.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/parser.py to parser.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/runtime.py to runtime.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/sandbox.py to sandbox.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/tests.py to tests.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/utils.py to utils.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/jinja2/visitor.py to visitor.cpython-36.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying Jinja2.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying Jinja2.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying Jinja2.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying Jinja2.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying Jinja2.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying Jinja2.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
jinja2.__pycache__.environment.cpython-36: module references __file__
jinja2.__pycache__.loaders.cpython-36: module references __path__
creating dist
creating 'dist/Jinja2-2.10.3-py3.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing Jinja2-2.10.3-py3.6.egg
creating /usr/local/lib/python3.6/site-packages/Jinja2-2.10.3-py3.6.egg
Extracting Jinja2-2.10.3-py3.6.egg to /usr/local/lib/python3.6/site-packages
Adding Jinja2 2.10.3 to easy-install.pth file

Installed /usr/local/lib/python3.6/site-packages/Jinja2-2.10.3-py3.6.egg
Processing dependencies for Jinja2==2.10.3
Searching for MarkupSafe==1.1.1
Best match: MarkupSafe 1.1.1
Adding MarkupSafe 1.1.1 to easy-install.pth file

Using /usr/local/lib64/python3.6/site-packages
Finished processing dependencies for Jinja2==2.10.3
[root@kubemaster Jinja2-2.10.3]#

압축을 해제한 디렉토리로 이동하여 setup.py 파일을 확인하고 위와 같이 python3 setup.py install 명령어로 설치를 진행합니다.

설치가 완료되면 다시한번 jinja2 버전을 확인합니다.

[root@kubemaster Jinja2-2.10.3]# pip3 show jinja2
Name: Jinja2
Version: 2.10.3
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/local/lib/python3.6/site-packages/Jinja2-2.10.3-py3.6.egg
Requires: MarkupSafe
[root@kubemaster Jinja2-2.10.3]#

위와 같이 정상적으로 설치 된 것을 확인할 수 있습니다.

일반적인 상황에서는 pip install로 손쉽게 설치가 가능하지만, 폐쇄망 환경에서 python private repository가 구축되어 있지 않은 경우에 유용하게 사용할 수 있을 듯 합니다.

728x90
반응형