You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS重装pip报错:/lib/python2.7/site-packages/不支持.pth文件

Fixing pip Reinstall Error on Mac: ".pth files not supported"

Hey there, let’s work through this pip reinstall issue you’re hitting on your Mac. That error about /lib/python2.7/site-packages/ not supporting .pth files and being outside your PYTHONPATH is a typical hiccup with older Python 2.7 setups (even though Python 2 is end-of-life, I totally get needing it for legacy tools). Here’s how to fix it:

  • First, check and update your PYTHONPATH
    The error says the target directory isn’t in your PYTHONPATH, so let’s fix that:

    1. Run this in terminal to see your current PYTHONPATH:
      echo $PYTHONPATH
      
    2. If /lib/python2.7/site-packages/ isn’t listed, add it temporarily with:
      export PYTHONPATH="/lib/python2.7/site-packages/:$PYTHONPATH"
      
    3. To make this permanent:
      • For bash users: Edit ~/.bash_profile and add the export line above, then run source ~/.bash_profile to apply changes.
      • For zsh users: Edit ~/.zshrc instead, then run source ~/.zshrc.
  • Fix directory permissions
    Sometimes the issue is just wonky permissions on the site-packages folder. Let’s verify and fix that:

    1. Check current permissions:
      ls -ld /lib/python2.7/site-packages/
      
    2. If the owner isn’t your user, reset ownership with:
      sudo chown -R $(whoami):staff /lib/python2.7/site-packages/
      
  • Skip easy_install—use get-pip.py directly
    easy_install is pretty outdated, so using the official get-pip script is often more reliable for Python 2.7:

    1. Download the Python 2.7-compatible get-pip.py script (available from PyPA’s legacy bootstrap resources).
    2. Install pip with:
      sudo python2.7 get-pip.py
      
  • Verify the install
    Once done, run this to confirm pip is working:

    pip2 --version
    

A quick side note: Python 2.7 has been unsupported since 2020, so if you can migrate your projects to Python 3, you’ll avoid a lot of these legacy issues going forward. But if you need Python 2.7 for specific tools, the steps above should get you sorted.

内容的提问来源于stack exchange,提问作者Garrett Perkins

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:38:32