• 2020. 5. 14.

    by. 윈썸지니

    반응형

    이번 포스팅은 파이썬 사용시 필수 적으로 사용하는 PIP에 대해 알아보고 설치해 봅니다.

     

    PIP 이란?

    pipPython Package Index (PyPI)라는 파이썬 패키지들을 모아 놓는 저장소로부터 파이썬 패키지를 받아 설치하는 패키지 관리 툴입니다.

    파이썬 2.7.9 이후 버전과 파이썬 3.4 이후 버전은 PIP를 기본적으로 포함하고 있습니다.

    PyPI third-party 파이썬 오픈소스 패키지들을 위한 저장소입니다.

     

    https://pypi.org/ 에서 현재 진행중인 프로젝트 및 릴리즈를 볼 수 있습니다.

    PIP 버전 확인을 해 봅니다.

    윈도우 로고 키 + R 을 입력해서 검색창에 cmd를 입력합니다.

    CMD 창에서 pip –version 을 입력하여 설치된 버전을 확인 합니다.

    Linux 의 경우 3.4 이상 버전 설치시 pip 명령어가 없다고 나오면 pip3 을 입력해 보세요.

    현재 설치되어 있는 파이썬 패키지 목록을 확인 합니다.

    pip list 라고 입력합니다.

    아래와 같이 현재는 설치된 패키지가 별로 없어서 아래와 같이 나옵니다.

    Pip 도 최신 버전이 있으니 업그레이드 하라고 경고가 뜨네요.

    너무 최신이면 보통 업그레이드 안 하지만 업그레이드 하는 방법을 알기 위해 한번 해 보겠습니다.

    Windows 환경의 명령어 입니다.

    python -m pip install --upgrade pip 명령어로 업그레이드 하고 다시 버전을 확인해 봅니다.

    Linux 환경 명령어 입니다.

    pip ( 또는 pip3) install –U pip

    만약 업그레이드 한 버전이 문제가 있으면 다운 그레이드 합니다.

    다운 그레이드 명령어 입니다.

    Python –m pip install pip==19.2.3 명령어로 다운 그레이드 하고 다시 버전을 확인해 봅니다.

    pip 사용법 알아보기

    Pip help 하면 명령어 사용법이 나옵니다.

    C:\Users>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.

    debug Show information useful for debugging.

    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

    패키지 상세 정보 보기

    pip show [package name] 이라고 하면 해당 패키지의 상세 정보를 보여 줍니다.

    패키지 설치

    pip install [package name] 이라고 하면 해당 패키지를 설치합니다.

    아래 예제는 requests 라는 패키지를 설치 한 예제 입니다.

    패키지 삭제

    Pip uninstall [package name] 이라고 하면 해당 패키지를 삭제 합니다.

    아래 예제는 위에서 설치한 requests 패키지를 삭제 합니다.

    패키지 업그레이드

    Pip install –upgrade [package name] 이라고 하면 해당 패키지를 업그레이드 합니다.

    Requests 패키지를 예로 들겠습니다.

    pip install --upgrade requests

    파이썬 PIP 사용법에 대해 간단히 알아 보았습니다.

    반응형