Python / PIP(Python Package Index) 사용법

Python Package Index

Python Package Index는 파이썬 패키지들이 모여 있는 저장소입니다.

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

pip 명령어로 패키지를 로컬 머신에 설치하고 삭제하고 업데이트할 수 있습니다.

PIP

pip는 파이썬으로 작성된 패키지 소프트웨어를 관리하는 패키지 관리 시스템입니다. 파이썬 2.7.9 이후 버전과 파이썬 3.4 이후 버전은 pip를 기본적으로 포함하고 있습니다.

pip는 [Windows PowerShell] 또는 [명령 프롬프트]에서 실행할 수 있습니다.

pip list

pip list 명령으로 현재 설치된 패키지 목록을 볼 수 있습니다. 업데이트가 필요한 패키지가 있는지도 알려줍니다.

PS C:\Users\JB> pip list
Package    Version
---------- -------
pip        21.2.4
setuptools 58.1.0
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the 'C:\Program Files\Python310\python.exe -m pip install --upgrade pip' command.

pip show package-name

pip show 다음에 패키지 이름을 넣으면, 그 패키지 정보가 출력됩니다.

PS C:\Users\JB> pip show pip
Name: pip
Version: 21.2.4
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: c:\program files\python310\lib\site-packages
Requires:
Required-by:

pip install package-name

pip install 명령으로 패키지를 설치합니다.(flake8은 작성한 코드가 코드 작성 기준에 맞는지 검토하는 패키지입니다.)

C:\Users\JB>pip install flake8
Collecting flake8
  Downloading https://files.pythonhosted.org/packages/e9/76/b915bd28976068a9843bf836b789794aa4a8eb13338b23581005cd9177c0/flake8-3.7.7-py2.py3-none-any.whl (68kB)
    100% |████████████████████████████████| 71kB 849kB/s
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in c:\users\jb\appdata\roaming\python\python37\site-packages (from flake8) (0.6.1)
Collecting pycodestyle<2.6.0,>=2.5.0 (from flake8)
  Downloading https://files.pythonhosted.org/packages/0e/0c/04a353e104d2f324f8ee5f4b32012618c1c86dd79e52a433b64fceed511b/pycodestyle-2.5.0-py2.py3-none-any.whl (51kB)
    100% |████████████████████████████████| 51kB 1.3MB/s
Collecting pyflakes<2.2.0,>=2.1.0 (from flake8)
  Downloading https://files.pythonhosted.org/packages/84/f2/ed0ffb887f8138a8fe5a621b8c0bb9598bfb3989e029f6c6a85ee66628ee/pyflakes-2.1.1-py2.py3-none-any.whl (59kB)
    100% |████████████████████████████████| 61kB 1.4MB/s
Collecting entrypoints<0.4.0,>=0.3.0 (from flake8)
  Downloading https://files.pythonhosted.org/packages/ac/c6/44694103f8c221443ee6b0041f69e2740d89a25641e62fb4f2ee568f2f9c/entrypoints-0.3-py2.py3-none-any.whl
Installing collected packages: pycodestyle, pyflakes, entrypoints, flake8
Successfully installed entrypoints-0.3 flake8-3.7.7 pycodestyle-2.5.0 pyflakes-2.1.1

패키지를 업그레이드하고 싶다면 --upgrade 옵션을 붙입니다.

C:\Users\JB>pip install --upgrade flake8

pip uninstall package-name

pip uninstall 명령으로 패키지를 삭제합니다.

C:\Users\JB>pip uninstall flake8
Uninstalling flake8-3.7.7:
  Would remove:
    c:\users\jb\appdata\local\programs\python\python37-32\lib\site-packages\flake8-3.7.7.dist-info\*
    c:\users\jb\appdata\local\programs\python\python37-32\lib\site-packages\flake8\*
    c:\users\jb\appdata\local\programs\python\python37-32\scripts\flake8.exe
Proceed (y/n)? y
  Successfully uninstalled flake8-3.7.7

pip help

C:\Users\JB>pip help

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to
                              WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
                              (a)bort).
  --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the
                              certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for
                              download. Implied with --no-index.
  --no-color                  Suppress colored output
같은 카테고리의 다른 글
Python / Visual Studio Code 개발 환경 만들기

Python / Visual Studio Code 개발 환경 만들기

파이썬 개발을 위한 도구는 여러 가지가 있습니다. Visual Studio Code도 그 중 하나입니다. VS Code에 Python 확장 기능을 설치하고, Hello World를 출력해보겠습니다. 확장 기능 설치 Visual Studio Code를 설치하고 실행합니다. 사각형 모양의 확장 기능 아이콘을 클릭합니다. python으로 검색한 후, 다운로드 수가 가장 많은 Microsoft가 만든 Python을 설치합니다. Reload Required를 클릭합니다.(VS Code 버전에 따라 나오지 않을 ...

Python / str() / 자료형을 문자열로 변환하는 함수

Python / str() / 자료형을 문자열로 변환하는 함수

str()은 데이터 타입을 문자열로 변환하는 함수이다. >>> a = 1 >>> type( a ) <class 'int'> >>> print( a ) 1 >>> b = str( a ) >>> type( b ) <class 'str'> >>> print( b ) 1 >>> a = 1.23 >>> type( a ) <class 'float'> >>> print( a ) 1.23 >>> b = str( a ) >>> type( b ) <class 'str'> >>> print( b ) 1.23 Python ...

Python / 윈도우에서 pip로 설치할 때 '액세스가 거부되었습니다.' 해결하는 방법

Python / 윈도우에서 pip로 설치할 때 '액세스가 거부되었습니다.' 해결하는 방법

윈도우에서 pip로 라이브러리를 설치할 때, 다음과 같은 에러가 나면서 설치가 되지 않을 수 있습니다. ERROR: Could not install packages due to an EnvironmentError: 액세스가 거부되었습니다: 'C:\\Program Files (x86)\\Python38-32\\Lib\\site-packages\\PIL' Consider using the `--user` option or check the permissions. 해당 폴더에 적절한 권한이 없어서 발생하는 문제로, 관리자 권한으로 CMD를 실행하면 해결됩니다.

Python / 조건문 / if

Python / 조건문 / if

if if 구문을 이용하면, 특정 조건을 만족할 때 특정 작업이 수행되도록 할 수 있습니다. 조건을 만족하는 동안 반복 작업을 하고 싶다면 while을 사용하세요. 문법 1 조건이 참이라면 코드를 실행합니다. if condition: statement 1은 0보다 크므로 HM을 출력합니다. if 1 > 0: print("HM") 조건이 거짓이므로 HM을 출력하지 않습니다. 즉, 아무런 작업을 하지 ...

Python / PIP(Python Package Index) 사용법

Python / PIP(Python Package Index) 사용법

Python Package Index Python Package Index는 파이썬 패키지들이 모여 있는 저장소입니다. The Python Package Index (PyPI) is a repository of software for the Python programming language. pip 명령어로 패키지를 로컬 머신에 설치하고 삭제하고 업데이트할 수 있습니다. PIP pip는 파이썬으로 작성된 패키지 소프트웨어를 관리하는 패키지 관리 시스템입니다. 파이썬 2.7.9 이후 버전과 파이썬 3.4 이후 버전은 pip를 ...

Python / 자료형 / 사전(dict)

Python / 자료형 / 사전(dict)

사전(dict) 사전은 집합의 일종으로, 키와 값이 하나의 데이터를 만듭니다. 순서가 없고 중복된 데이터를 갖지 않아서, 중복 데이터를 만드는 +, *를 사용할 수 없지만, 키를 이용하여 인덱스기호()를 사용할 수 있습니다. 사전 만들기 사전은 집합과 마찬가지로 중괄호로 만듭니다. 키를 앞에, 값을 뒤에 쓰고, 구분은 콜론(:)으로 합니다. 데이터의 구분은 쉼표(,)로 합니다. >>> jb = {1:"one", 2:"two", 3:"three"} >>> jb {1: 'one', ...

Python / type() / 데이터 타입(자료형) 확인하는 함수

Python / type() / 데이터 타입(자료형) 확인하는 함수

type() type()은 데이터 타입을 확인할 수 있는 함수입니다. 예제 123의 데이터 타입을 확인합니다. 결과는 정수입니다. >>> type(123) <class 'int'> 변수에 데이터를 담고, 변수 이름으로 데이터 타입을 확인할 수 있습니다. >>> jb = 123 >>> type(jb) <class 'int'> print() 함수로 결과를 출력할 수 있습니다. 쉘에서는 결과가 같지만, 실제 프로그램 실행시에는 데이터 타입이 출력됩니다. >>> jb = 123 >>> print(type(jb)) <class 'int'> 다음은 여러 가지 데이터의 ...

Python / PyCharm 설치하는 방법

Python / PyCharm 설치하는 방법

PyCharm는 Python 개발 도구 중의 하나입니다. JetBrains에서 만든 것으로, 모든 기능이 있는 프로페셔널 에디션과, 기능의 제한이 있지만 무료로 사용할 수 있는 커뮤니티 에디션이 있습니다. 아래는 OS가 Windows인 컴퓨터에 PyCharm 커뮤니티 에디션을 다운로드하고 설치하는 방법입니다. 참고로, Python이 설치되어 있지 않아도 괜찮습니다. PyCharm에서 프로젝트를 만들 때 자동으로 Python을 다운로드 합니다. PyCharm 페이지에서 를 클릭합니다. Community ...

Python / input() / 사용자가 입력한 값을 변수에 저장하는 함수

Python / input() / 사용자가 입력한 값을 변수에 저장하는 함수

input() 함수로 사용자가 어떤 값을 입력하게 하고, 그 값을 변수에 저장할 수 있습니다. 문법 예를 들어 다음을 입력하고 엔터를 누르면 사용자가 값을 입력하기를 기다립니다. >>> x = input() 값을 입력하고 엔터를 누르면 그 값이 변수 x에 저장됩니다. >>> x = input() hello >>> x 'hello' 입력할 값에 대한 안내를 출력하고 싶다면 다음과 같이 합니다. >>> x = input('some text') 작은 따옴표 ...

Python / 자료형 / 집합(set)

Python / 자료형 / 집합(set)

집합(set) 집합은 여러 개의 자료를 하나의 변수로 관리할 때 사용하는 자료형 중의 하나입니다. 집합 자료형은 수학의 집합과 같은 성질을 가집니다. 즉, 집합은 중복된 데이터를 가질 수 없고, 순서가 없습니다. 따라서 순서와 관련된 인덱스기호()를 사용할 수 없고, 중복 데이터를 만드는 +, *를 사용할 수 없습니다. 하지만, in, not in, len()은 사용할 수 있습니다. 집합 만들기 집합은 중괄호로 만듭니다. >>> ...