Python / PIP 사용법

PIP

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

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

pip list

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

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 다음에 패키지 이름을 넣으면, 그 패키지 정보가 출력됩니다.

C:\Users\jb> pip show pip
Name: pip
Version: 25.3
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author:
Author-email: The pip developers <distutils-sig@python.org>
License-Expression: MIT
Location: C:\Users\jb\AppData\Roaming\Python\Python314\site-packages
Requires:
Required-by:

pip install package-name

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

C:\Users\jb> pip unstall flake8
ERROR: unknown command "unstall" - maybe you meant "uninstall"
PS C:\Users\jb> pip install flake8
Defaulting to user installation because normal site-packages is not writeable
Collecting flake8
  Downloading flake8-7.3.0-py2.py3-none-any.whl.metadata (3.8 kB)
Collecting mccabe<0.8.0,>=0.7.0 (from flake8)
  Downloading mccabe-0.7.0-py2.py3-none-any.whl.metadata (5.0 kB)
Collecting pycodestyle<2.15.0,>=2.14.0 (from flake8)
  Downloading pycodestyle-2.14.0-py2.py3-none-any.whl.metadata (4.5 kB)
Collecting pyflakes<3.5.0,>=3.4.0 (from flake8)
  Downloading pyflakes-3.4.0-py2.py3-none-any.whl.metadata (3.5 kB)
Downloading flake8-7.3.0-py2.py3-none-any.whl (57 kB)
Downloading mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
Downloading pycodestyle-2.14.0-py2.py3-none-any.whl (31 kB)
Downloading pyflakes-3.4.0-py2.py3-none-any.whl (63 kB)
Installing collected packages: pyflakes, pycodestyle, mccabe, flake8
  WARNING: The script pyflakes.exe is installed in 'C:\Users\jb\AppData\Roaming\Python\Python314\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/4 [pyflakes]  WARNING: The script pycodestyle.exe is installed in 'C:\Users\jb\AppData\Roaming\Python\Python314\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━ 3/4 [flake8]  WARNING: The script flake8.exe is installed in 'C:\Users\jb\AppData\Roaming\Python\Python314\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed flake8-7.3.0 mccabe-0.7.0 pycodestyle-2.14.0 pyflakes-3.4.0

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

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

pip uninstall package-name

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

C:\Users\jb> pip uninstall flake8
Found existing installation: flake8 7.3.0
Uninstalling flake8-7.3.0:
  Would remove:
    c:\users\jb\appdata\roaming\python\python314\scripts\flake8.exe
    c:\users\jb\appdata\roaming\python\python314\site-packages\flake8-7.3.0.dist-info\*
    c:\users\jb\appdata\roaming\python\python314\site-packages\flake8\*
Proceed (Y/n)? y
  Successfully uninstalled flake8-7.3.0

pip help

C:\Users\jb> pip help

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  lock                        Generate a lock file.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  inspect                     Inspect the python environment.
  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.
  cache                       Inspect and manage pip's wheel cache.
  index                       Inspect information available from package indexes.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --debug                     Let unhandled exceptions propagate outside the main subroutine, instead of logging them to stderr.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  --require-virtualenv        Allow pip to only run in a virtual environment; exit with an error otherwise.
  --python <python>           Run pip with the specified Python interpreter.
  -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.
  --no-input                  Disable prompting for input.
  --keyring-provider <keyring_provider>
                              Enable the credential lookup via the keyring library if user input is allowed. Specify which mechanism to
                              use [auto, disabled, import, subprocess]. (default: auto)
  --proxy <proxy>             Specify a proxy in the form scheme://[user:passwd@]proxy.server:port.
  --retries <retries>         Maximum attempts to establish a new HTTP connection. (default: 5)
  --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 or host:port pair as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to PEM-encoded CA certificate bundle. If provided, overrides the default. See 'SSL Certificate
                              Verification' in pip documentation for more information.
  --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.
  --use-feature <feature>     Enable new functionality, that may be backward incompatible.
  --use-deprecated <feature>  Enable deprecated functionality, that will be removed in the future.
  --resume-retries <resume_retries>
                              Maximum attempts to resume or restart an incomplete download. (default: 5)
같은 카테고리의 다른 글

Python / Pandas / 엑셀 파일들을 CSV로 변환하고 병합하는 방법

시트가 하나인 엑셀 파일을 CSV로 변환 import pandas as pd df = pd.read_excel( "excel_1.xlsx" ) df.to_csv( "csv_1.csv", index = False, encoding = "utf-8-sig", ) 시트가 여러 개인 엑셀 파일을 CSV로 변환 import pandas as pd xlsx = pd.ExcelFile( "excel_2.xlsx" ) dfs = for sheet in xlsx.sheet_names: df = pd.read_excel( xlsx, sheet_name = sheet ) ...

Python / PIP 사용법

Python / PIP 사용법

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

Python / 설치 / 윈도우에 설치하기

Python / 설치 / 윈도우에 설치하기

Windows를 OS로 하는 컴퓨터에 Python을 설치하는 방법입니다.

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

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

파이썬 개발을 위한 도구는 여러 가지가 있습니다. Visual Studio Code도 그 중 하나입니다. VS Code에 Python 확장 기능을 설치하고, Hello World를 출력해보겠습니다.