Installing Python modules¶
As a popular open source development project, Python has an active supporting community of contributors and users that also make their software available for other Python developers to use under open-source license terms.
이를 통해 파이썬 사용자는 효과적으로 공유하고 공동 작업할 수 있으며, 다른 사람들이 공통 (심지어 때로는 희귀한) 문제에 대해 이미 만든 솔루션의 이점을 누릴 수 있을 뿐 아니라, 자체 솔루션을 공동 풀에 잠재적으로 제공할 수 있습니다.
이 지침서는 이 절차의 설치 부분을 다룹니다. 자신의 파이썬 프로젝트를 만들고 공유하는 지침은 Python packaging user guide를 참조하십시오.
참고
기업 및 기타 기관 사용자의 경우, 많은 조직에서 공개 소스 소프트웨어를 사용하고 공헌하는 데 대한 자체 정책을 시행하고 있음을 알고 있어야 합니다. 파이썬과 함께 제공되는 배포 및 설치 도구를 사용할 때 이러한 정책을 고려하십시오.
핵심 용어¶
pip is the preferred installer program. It is included by default with the Python binary installers.
가상 환경 은 패키지가 시스템 전체에 설치되는 것이 아니라, 특정 응용 프로그램에 사용되도록 설치될 수 있도록 하는 반 격리 된 파이썬 환경입니다.
venvis the standard tool for creating virtual environments. It defaults to installing pip into all created virtual environments.virtualenvis a third-party alternative (and predecessor) tovenv.The Python Package Index (PyPI) is a public repository of open source licensed packages made available for use by other Python users.
The Python Packaging Authority is the group of developers and documentation authors responsible for the maintenance and evolution of the standard packaging tools and the associated metadata and file format standards. They maintain a variety of tools, documentation, and issue trackers on GitHub.
버전 3.5에서 변경: 이제 가상 환경을 만드는데 venv 사용을 권장합니다.
기본 사용법¶
표준 패키징 도구는 모두 명령 줄에서 사용하도록 설계되었습니다.
The following command will install the latest version of a module and its dependencies from PyPI:
python -m pip install SomePackage
참고
POSIX 사용자(맥 OS 와 리눅스 사용자를 포함합니다)의 경우, 이 지침서의의 예제는 가상 환경 을 사용한다고 가정합니다.
윈도우 사용자의 경우, 이 지침서의 예제는 파이썬을 설치할 때 시스템 PATH 환경 변수를 조정하는 옵션이 선택되었다고 가정합니다.
정확한 버전이나 최소 버전을 명령 줄에서 직접 지정할 수도 있습니다. >, < 와 같은 비교 연산자나 셸에서 해석되는 다른 특수 문자를 사용할 때는, 패키지 이름과 버전을 큰따옴표로 묶어야 합니다:
python -m pip install SomePackage==1.0.4 # 특정 버전
python -m pip install "SomePackage>=1.0.4" # 최소 버전
일반적으로, 적절한 모듈이 이미 설치되어있으면, 다시 설치하려고 해도 아무런 효과가 없습니다. 기존 모듈을 업그레이드하려면 명시적으로 요청해야 합니다:
python -m pip install --upgrade SomePackage
More information and resources regarding pip and its capabilities can be found in the Python Packaging User Guide.
가상 환경의 생성은 venv 모듈을 통해 수행됩니다. 활성 가상 환경에 패키지를 설치하려면 위에 표시된 명령을 사용합니다.
어떻게 …?¶
이것들은 몇 가지 일반적인 작업에 대한 빠른 답변 또는 링크입니다.
… 현재 사용자만을 위해 패키지를 설치합니까?¶
--user 옵션을 python -m pip install 에 넘겨주면 시스템의 모든 사용자가 아닌 현재 사용자를 위해서만 패키지를 설치합니다.
… 과학 계산용 파이썬 패키지를 설치합니까?¶
A number of scientific Python packages have complex binary dependencies, and aren’t currently easy to install using pip directly. It will often be easier for users to install these packages by other means rather than attempting to install them with pip.
… 병렬로 설치된 여러 버전의 파이썬으로 작업합니까?¶
On Linux, macOS, and other POSIX systems, use the versioned Python commands
in combination with the -m switch to run the appropriate copy of
pip:
python3 -m pip install SomePackage # default Python 3
python3.14 -m pip install SomePackage # specifically Python 3.14
Appropriately versioned pip commands may also be available.
On Windows, use the py Python launcher in combination with the -m
switch:
py -3 -m pip install SomePackage # default Python 3
py -3.14 -m pip install SomePackage # specifically Python 3.14
흔히 만나는 설치 문제¶
리눅스에 시스템 파이썬 설치하기¶
On Linux systems, a Python installation will typically be included as part of the distribution. Installing into this Python installation requires root access to the system, and may interfere with the operation of the system package manager and other components of the system if a component is unexpectedly upgraded using pip.
On such systems, it is often better to use a virtual environment or a per-user installation when installing packages with pip.
Pip가 설치되지 않았습니다.¶
It is possible that pip does not get installed by default. One potential fix is:
python -m ensurepip --default-pip
There are also additional resources for installing pip.
바이너리 확장 설치하기¶
Python once relied heavily on source-based distribution, with end users being expected to compile extension modules from source as part of the installation process.
With the introduction of the binary wheel format, and the ability to publish wheels through PyPI, this problem is diminishing, as users are more regularly able to install pre-built extensions rather than needing to build them themselves.
Some of the solutions for installing scientific software that are not yet available as pre-built wheel files may also help with obtaining other binary extensions without needing to build them locally.