프로그래밍 Programming
PIP로 특정 버전 패키지 설치하는 법 To install a specific version of a package with pip
문장전달자
2017. 2. 20. 16:38
최신 버전의 패키지가 아니라 특정 버전의 패키지까지만 지원하는 경우 등 이미 설치된 최신 버전을 제거하고 지원가능한 특정 버전 설치는 다음과 같이 한다.
Use ==:
1 2 3 4 5 6 7 8 9 10 11 12 | # pip install twisted==16.2.0 Collecting twisted==16.2.0 Downloading Twisted-16.2.0.tar.bz2 (2.9MB) 100% |████████████████████████████████| 2.9MB 100kB/s Requirement already satisfied: zope.interface>=4.0.2 in /root/anaconda/envs/envalicia/lib/python3.5/site-packages (from twisted==16.2.0) Requirement already satisfied: setuptools in /root/anaconda/envs/envalicia/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg (from zope.interface>=4.0.2->twisted==16.2.0) Building wheels for collected packages: twisted Running setup.py bdist_wheel for twisted ... done Stored in directory: /root/.cache/pip/wheels/fe/9d/3f/9f7b1c768889796c01929abb7cdfa2a9cdd32bae64eb7aa239 Successfully built twisted Installing collected packages: twisted Successfully installed twisted-16.2.0 | cs |
설치된 버전 확인. 기존에는 17.1.0 버전이 설치되어 있었다.
1 2 3 4 5 6 7 8 9 10 | # python Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import pip >>> installed_packages = pip.get_installed_distributions() >>> installed_packages_list = sorted(["%s==%s" % (i.key, i.version) for i in pip.get_installed_distributions()]) >>> print(installed_packages_list) [ 'twisted==16.2.0' ] >>> | cs |