developer tip

easy_install보다 pip를 사용하는 이유는 무엇입니까?

optionbox 2020. 9. 28. 09:01
반응형

easy_install보다 pip를 사용하는 이유는 무엇입니까? [닫은]


트윗

얼굴을 찌르는 것을 좋아하지 않는 한 easy_install을 사용하지 마십시오. pip를 사용하십시오.

easy_install보다 pip를 사용하는 이유는 무엇입니까? 되지는 않습니다 대부분 PyPI 및 패키지 저자와 고장 거짓말 ? 작성자가 크랩 소스 tarball (예 : 누락 된 파일, setup.py 없음)을 PyPI에 업로드하면 pip와 easy_install이 모두 실패합니다. 화장품의 차이 이외에, 왜 (위의 트윗처럼) 파이썬 사람들이 보인다 할 강하게 easy_install을 통해 핍을 선호?

(커뮤니티에서 유지 관리하는 Distribute 패키지의 easy_install에 대해 이야기하고 있다고 가정 해 보겠습니다.)


여기에있는 많은 답변은 2015 년에 대해 구식입니다 ( Daniel Roseman에서 처음 수락 한 답변 은 그렇지 않지만). 현재 상황은 다음과 같습니다.

  • 바이너리 패키지는 이제 .whlPyPI뿐만 아니라 Christoph Gohlke의 Windows 용 확장 패키지 와 같은 타사 리포지토리에 바퀴 ( 파일) 로 배포됩니다 . pip바퀴를 다룰 수 있습니다; easy_install할 수 없습니다.
  • 가상 환경 (3.4에 내장되거나를 사용하여 2.6 + / 3.1 +에 추가 될 수 있음 virtualenv)은 매우 중요하고 눈에 띄는 도구가되었습니다 (그리고 공식 문서 에서 권장 됨 ). 그들은 기본적으로 포함 pip되지만 easy_install.
  • distribute포함하는 것이 패키지는 easy_install더 이상 유지되지 않습니다. 이상 그것의 개선 setuptools당함 뒷면에 합병 setuptools. 설치 distribute시도하면 setuptools대신 설치 됩니다.
  • easy_install 그 자체는 유사하게 유지됩니다.
  • 압축을 푼 소스 트리, DVCS 리포지토리 등에서 설치 pip하는 것보다 열등 했던 모든 경우 easy_install는 오래 전입니다. 당신은 할 수 있습니다 pip install ., pip install git+https://.
  • pippython.org의 공식 Python 2.7 및 3.4+ 패키지와 함께 제공되며 pip소스에서 빌드하는 경우 기본적으로 부트 스트랩이 포함됩니다.
  • 패키지 설치, 사용 및 빌드에 대한 여러 가지 불완전한 문서가 Python Packaging User Guide 로 대체되었습니다 . Python 모듈 설치 에 대한 Python의 자체 문서는 이제이 사용자 가이드를 따르며 pip"선호하는 설치 프로그램"이라고 명시 적으로 호출합니다 .
  • 다른 새로운 기능은에 pip없을 것입니다 수년 걸쳐 추가되었습니다 easy_install. 예를 들어, pip요구 사항 파일을 빌드 한 다음 양쪽에 단일 명령으로 설치하여 사이트 패키지를 쉽게 복제 할 수 있습니다. 또는 사내 개발에 사용하기 위해 요구 사항 파일을 로컬 저장소로 변환합니다. 등등.

내가 easy_install2015 년 에 사용해야하는 유일한 이유는 OS X 10.5-10.8에서 Apple의 사전 설치된 Python 버전을 사용하는 특별한 경우입니다. 10.5 이후 Apple easy_install은를 포함 했지만 10.10 부터는 여전히 pip. 10.9+에서는 여전히을 사용해야하지만 10.5-10.8의 경우 get-pip.py몇 가지 문제가 있으므로 sudo easy_install pip. (일반적으로 easy_install pip이것은 나쁜 생각입니다. OS X 10.5-10.8에만 해당됩니다.) 또한 10.5-10.8은 kludge readline하는 방법을 easy_install알고 있지만 pip그렇지 않은 방식으로 포함 합니다. sudo easy_install readline업그레이드하려면.


Ian Bicking의 pip 소개에서 :

pip는 원래 easy_install을 다음과 같이 개선하기 위해 작성되었습니다.

  • 모든 패키지는 설치 전에 다운로드됩니다. 결과적으로 부분적으로 완료된 설치가 발생하지 않습니다.
  • 콘솔에 유용한 출력을 표시하도록주의를 기울입니다.
  • 행동의 이유는 계속 추적됩니다. 예를 들어 패키지가 설치되는 경우 pip는 해당 패키지가 필요한 이유를 추적합니다.
  • 오류 메시지가 유용해야합니다.
  • 코드는 비교적 간결하고 응집력이있어 프로그래밍 방식으로 사용하기가 더 쉽습니다.
  • 패키지는 달걀 아카이브로 설치할 필요가 없으며, 평평하게 설치할 수 있습니다 (에그 메타 데이터를 유지하면서).
  • 다른 버전 제어 시스템 (Git, Mercurial 및 Bazaar)에 대한 기본 지원
  • 패키지 제거.
  • 고정 된 요구 사항 세트를 간단하게 정의하고 패키지 세트를 안정적으로 재현합니다.

아직 언급되지 않은 또 다른 이유는 을 선호하는 또 다른 이유 는 이것이 새로운 핫 니스이며 앞으로도 계속 사용될 것입니다.

The Hitchhiker 's Guide to Packaging v1.0Current State of Packaging 섹션에있는 아래의 인포 그래픽 은 setuptools / easy_install이 앞으로 사라질 것임을 보여줍니다.

여기에 이미지 설명 입력

다음 Setuptools 및 easy_install이 새로운 핫 니스 인 배포pip 로 대체 될 것임을 보여주는 배포 설명서 의 또 다른 인포 그래픽입니다 . 하지만 핍은 여전히 새로운 섹시한 레이저입니다, 배포 샘플 과 합병 setuptools에 의 출시와 함께 2013 년 setuptools에 v0.7.

여기에 이미지 설명 입력


두 가지 이유는 다음과 같습니다.

  1. pip는 uninstall명령을 제공합니다

  2. 중간에 설치가 실패하면 pip는 당신을 깨끗한 상태로 남겨 둘 것입니다.


REQUIREMENTS 파일.

진지하게, 나는 이것을 매일 virtualenv와 함께 사용합니다.


빠른 종속성 관리 자습서, FOLKS

Requirements files allow you to create a snapshot of all packages that have been installed through pip. By encapsulating those packages in a virtualenvironment, you can have your codebase work off a very specific set of packages and share that codebase with others.

From Heroku's documentation https://devcenter.heroku.com/articles/python

You create a virtual environment, and set your shell to use it. (bash/*nix instructions)

virtualenv env
source env/bin/activate

Now all python scripts run with this shell will use this environment's packages and configuration. Now you can install a package locally to this environment without needing to install it globally on your machine.

pip install flask

Now you can dump the info about which packages are installed with

pip freeze > requirements.txt

If you checked that file into version control, when someone else gets your code, they can setup their own virtual environment and install all the dependencies with:

pip install -r requirements.txt

Any time you can automate tedium like this is awesome.


pip won't install binary packages and isn't well tested on Windows.

As Windows doesn't come with a compiler by default pip often can't be used there. easy_install can install binary packages for Windows.


UPDATE: setuptools has absorbed distribute as opposed to the other way around, as some thought. setuptools is up-to-date with the latest distutils changes and the wheel format. Hence, easy_install and pip are more or less on equal footing now.

Source: http://pythonhosted.org/setuptools/merge-faq.html#why-setuptools-and-not-distribute-or-another-name


As an addition to fuzzyman's reply:

pip won't install binary packages and isn't well tested on Windows.

As Windows doesn't come with a compiler by default pip often can't be used there. easy_install can install binary packages for Windows.

Here is a trick on Windows:

  • you can use easy_install <package> to install binary packages to avoid building a binary

  • you can use pip uninstall <package> even if you used easy_install.

This is just a work-around that works for me on windows. Actually I always use pip if no binaries are involved.

See the current pip doku: http://www.pip-installer.org/en/latest/other-tools.html#pip-compared-to-easy-install

I will ask on the mailing list what is planned for that.

Here is the latest update:

The new supported way to install binaries is going to be wheel! It is not yet in the standard, but almost. Current version is still an alpha: 1.0.0a1

https://pypi.python.org/pypi/wheel

http://wheel.readthedocs.org/en/latest/

I will test wheel by creating an OS X installer for PySide using wheel instead of eggs. Will get back and report about this.

cheers - Chris

A quick update:

The transition to wheel is almost over. Most packages are supporting wheel.

I promised to build wheels for PySide, and I did that last summer. Works great!

HINT: A few developers failed so far to support the wheel format, simply because they forget to replace distutils by setuptools. Often, it is easy to convert such packages by replacing this single word in setup.py.


Just met one special case that I had to use easy_install instead of pip, or I have to pull the source codes directly.

For the package GitPython, the version in pip is too old, which is 0.1.7, while the one from easy_install is the latest which is 0.3.2.rc1.

I'm using Python 2.7.8. I'm not sure about the underlay mechanism of easy_install and pip, but at least the versions of some packages may be different from each other, and sometimes easy_install is the one with newer version.

easy_install GitPython

참고 URL : https://stackoverflow.com/questions/3220404/why-use-pip-over-easy-install

반응형