Mathurada Ekkapat
2 min readFeb 7, 2019

[Day1] Automate Test

ใช้ pip ติดตั้งโมดูลง่ายกว่าเยอะ

สวัสดีครับทุกท่าน หลังจากที่ Python มี pip ทำให้การติดตั้งโมดูลเป็นไปได้อย่างสะดวก รวดเร็วยิ่งขึ้น ทั้ง Python 2 , 3 บทความนี้ท่านใดใช้ pip ติดตั้งโมดูลได้แล้ว สามารถข้ามไปได้เลยนะครับ pip จะมาพร้อมกับ Python 2.7 กับ Python 3.4 + นะครับ สำหรับท่านใดที่ใช้รุ่นเก่ากว่านี้ให้ทำตามนี้ครับ https://pip.pypa.io/en/latest/installing.html

การใช้ pip ใน Windows

ก่อนเริ่มใช้งานต้องเพิ่มค่าตัวแปรในระบบก่อนครับ เราต้องไปเพิ่มค่า PATH variable ในระบบเพื่อเรียกใช้งาน Python components และ packages ต่าง ๆ

  1. คลิก Computer และเลือก Properties.
  2. ช่องด้านซ้ายมือเลือก Advanced System Settings. (หมายเลข 1)
  3. เลือก Environment Variables. (หมายเลข 2)
  4. ในช่องให้เลือก PATH แล้วคลิกปุ่ม edit ให้ใส่ C:\PythonXX;C:\PythonXX\Lib\site-packages\;C:\PythonXX\Scripts\; ลงไป XX คือเลขเวชั่นของ Python ครับ
  5. กด ok

เปิด คอมมานด์ไลน์ ขึ้นมา โดยใช้กดปุ่มบนคีย์บอร์ด Windows + R แล้วจะมีหน้าตาขึ้นมา

แล้วพิมพ์ cmd แล้วกด ok จะเจอกับหน้าตา คอมมานด์ไลน์

แล้วให้ใส่คำสั่งสำหรับติดตั้งโมดูลด้วย pip ลงไป
pip install ชื่อโมดูล
ตัวอย่างช่นผมต้องการติดตั้ง Pyside
pip install pyside
ครับ

การใช้ pip ใน Linux

เปิด Terminal ขึ้นมา ถ้าใช้ในโหมด GUI ใช้คีย์ลัด Ctrl + Alt + T ครับ
แล้วให้ใส่คำสั่งสำหรับติดตั้งโมดูลด้วย pip ลงไป
pip install ชื่อโมดูล
ครับ

การใช้ pip ใน Mac OS

เปิด Terminal ขึ้นมา http://www.wikihow.com/Get-to-the-Command-Line-on-a-Mac
แล้วใช้คำสั่ง
pip install ชื่อโมดูล
ได้เลยครับ

ติดตามบทความต่อไปนะครับ
ขอบคุณครับ

cr.https://python3.wannaphong.com/2014/10/pip-install-mod.html

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response