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

M1芯片MacBook Pro(Monterey系统)更新Python3.10后出现libreadline.7.dylib加载失败及命令无法调用问题求助

Fixing "Library not loaded: libreadline.7.dylib" & Missing Commands on M1 Mac Monterey

Hey there, let's get your Mac back up and running step by step—no need to panic, this is a common dependency linking issue after adjusting brew and Python versions!

What's Going On?

The error happens because gawk (a tool brew relies on) is still looking for an old version of the readline library (version 7), but your system only has the newer 8.1.1 version installed. On top of that, your terminal's command search path (PATH) got messed up, so it can't find basic system tools like awk, sed, or dirname.

Step-by-Step Fixes

1. Restore Basic Command Access First

First, we need to tell your terminal to use the system's built-in tools temporarily. Run this command in your terminal:

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"

This adds the system's default command folders to the top of your path, so tools like awk and sed will work again right away.

2. Fix the Readline Library Issue

We have two ways to fix this—start with the first (cleaner) option:

  • Option 1: Reinstall gawk to match your current readline version
    Now that basic commands work, run this to reinstall gawk so it uses the newer readline library:
    brew reinstall gawk
    
  • Option 2: Create a temporary link (if brew still won't run)
    If brew is still unresponsive, create a soft link to trick gawk into using the newer library:
    sudo ln -s /usr/local/Cellar/readline/8.1.1/lib/libreadline.8.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
    
    You'll need to enter your Mac password when prompted (it won't show on screen, that's normal).

3. Fix Python & Brew Linking

Now let's get Python 3.10 linked correctly with brew:

  • First, check if Python 3.10 is installed:
    brew list python@3.10
    
  • If it's there, link it (add --overwrite if you get a conflict message):
    brew link python@3.10
    # Or if there's a conflict:
    brew link --overwrite python@3.10
    

4. Verify Everything Works

Close your terminal completely, then open a new one. Test these commands to make sure things are fixed:

python --version  # Should show Python 3.10.x
awk --version     # Should run without errors
brew --version    # Should show your brew version

Tips for the Future

  • When updating Python with brew, use brew install python@3.10 instead of manually unlinking old versions—brew handles dependencies better this way.
  • If you need to switch between multiple Python versions, consider using pyenv (it's safer and won't mess with brew or system tools). Just install it via brew: brew install pyenv and follow the simple setup instructions.

内容的提问来源于stack exchange,提问作者RubyRed Kinetix

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 23:27:33