Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

ใช้ easy_install ติดตั้งโมดูล Python (และทำไมควรใช้ pip แทน)

easy_install เปิดตัวปี 2004 ส่วนหนึ่งของ setuptools เน้นติดตั้งจาก PyPI และดึง Dependency อัตโนมัติ

ทำไมต้องเปลี่ยนมาใช้ pip?

  • pip ปล่อยปี 2008 แก้จุดอ่อนของ easy_install
  • รองรับการ Uninstall, Upgrade, Requirements File
  • จัดการ Dependency ดีกว่า ลดปัญหา Broken Environment
  • เป็นมาตรฐานปัจจุบัน (PEP 453)

ย้ายจาก easy_install ไป pip

$ easy_install pip

คำสั่ง pip พื้นฐาน

# ติดตั้งล่าสุด
$ pip install 'SomeProject'

# ติดตั้งเวอร์ชันเฉพาะ
$ pip install 'SomeProject==1.4'

# ติดตั้งช่วงเวอร์ชัน
$ pip install 'SomeProject>=1,<2'