Tag Archive Python

Byphunsanit

Homebrew: ติดตั้งไพทอน

ขั้นตอนการติดตั้งไพทอน (Python) โดยใช้ homebrew บน mac เพื่อที่จะได้ใช้ automate test อย่าง Selenium

  1. ติดตั้ง homebrew ก่อนถ้ายังไม่มี
    หากใช้ windows ทำตาม WSL: Homebrew install
  2. เปิด terminal แล้วใช้
    brew install python
  3. เช็คโดยคำสั่ง
    brew info python
    จะเห็นการตอบกลับมา เช่น
    [email protected]: stable 3.14.0 (bottled)
    Interpreted, interactive, object-oriented programming language
    https://www.python.org/
    Installed
    /opt/homebrew/Cellar/[email protected]/3.14.0_1 (3,802 files, 70.5MB) *
    Poured from bottle using the formulae.brew.sh API on 2025-11-08 at 22:15:22
    From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/p/[email protected]
    License: Python-2.0
    >==> Dependencies>
    Build: pkgconf ✘
    Required: mpdecimal ✔, openssl@3 ✔, sqlite ✔, xz ✔, zstd ✔
    ==> Caveats
    Python is installed as
    /opt/homebrew/bin/python3

    Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to>
    `python3`, `python3-config`, `pip3` etc., respectively, are installed into
    /opt/homebrew/opt/[email protected]/libexec/bin

    `idle3.14` requires tkinter, which is available separately:
    brew install [email protected]

    See: https://docs.brew.sh/Homebrew-and-Python
  4. จากนั้นใส่ environment variables
    echo 'export PATH="/opt/homebrew/opt/[email protected]/libexec/bin:$PATH"' >> ~/.zshrc
    โดย path ที่ระบุลงไปคือ หลังข้อความ are installed into

การทดสอบความพร้อมเบื้องต้น

  1. ให้เปิด Terminal ใหม่และใช้คำสั่ง
  2. ใช้คำสั่ง
    which python
    จะบอกว่า environment variables ถูกชี้ไปที่ไหน เช่น
    /opt/homebrew/opt/[email protected]/libexec/bin/python
  3. ดู version ของ python โดย
    python --version
    ควรจะตอบเป็น
    Python 3.14.
  4. และคำสั่ง
    pip3 --version
    จะตอบมาประมาณ
    pip 25.3 from /Users/phunsanit/Library/Python/3.9/lib/python/site-packages/pip (python 3.9)

เท่านี้ก็จะเป็นการลง python ที่สามารถใช้ได้ในการใช้ Selenium มาเทส

อ่านเพิ่มเติม