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

终端Python版本切换咨询:卸载残留及PyCharm检测不到Python3.7问题

Hey Kayla, let's tackle your questions one by one to get everything working smoothly again!

Why do MAMP/Python 2.7 traces still show up in Terminal after uninstall?

There are a few common reasons for this:

  • System-preinstalled Python 2.7: If you're on a macOS version older than Monterey, Apple preinstalls Python 2.7 by default. Uninstalling your manually installed Python 2.7 won't remove this system version, so python might still point to it.
  • Residual environment variables: MAMP and custom Python installs often add paths to your shell configuration files (like ~/.bash_profile, ~/.zshrc, or ~/.profile). If you didn't delete these entries during uninstall, Terminal will still look for the old programs in those paths.
  • Shell command cache: Terminal stores command paths in a hash table to speed things up. Even after you delete the program, the cached path might still exist, making it seem like the old version is still there.

How to set Python 3.7 as Terminal's default version?

Follow these steps:

  1. First, find where Python 3.7 is installed by running this command:
    which python3.7
    
    You'll get a path like /usr/local/bin/python3.7 – note this down.
  2. Update your shell configuration:
    • If you use Bash: Open ~/.bash_profile in a text editor, add this line (replace the path with your actual one):
      alias python="/usr/local/bin/python3.7"
      
      Save the file, then run source ~/.bash_profile to apply the changes immediately.
    • If you use Zsh: Do the same but edit ~/.zshrc instead, then run source ~/.zshrc.
      Alternatively, you can prioritize the Python 3.7 path in your PATH variable (more robust for scripts):
    export PATH="/usr/local/bin:$PATH"
    
    (Make sure /usr/local/bin is the folder containing your python3.7 executable.)
  3. Clear the shell cache to avoid old paths sticking around:
    hash -r
    
  4. Verify the change: Close and reopen Terminal, then run python --version – it should show Python 3.7.

Fixing PyCharm not detecting Python 3.7

Try these steps to get PyCharm to recognize your Python 3.7 install:

  1. Manually add the interpreter:
    • Open PyCharm, go to File > Settings (Windows/Linux) or PyCharm > Preferences (macOS).
    • Navigate to Project: [Your Project Name] > Python Interpreter.
    • Click the gear icon in the top-right corner, select Add.
    • Choose System Interpreter, then click the ... button to browse for your Python 3.7 executable (use the path you found earlier with which python3.7). Select it and click OK.
  2. Check PyCharm compatibility: Make sure your PyCharm version supports Python 3.7 – versions 2019.1 and newer do. If you're on an older version, consider updating PyCharm.
  3. Confirm Python 3.7 is properly installed: Run python3.7 -m pip --version in Terminal. If this returns an error, your Python 3.7 install might be corrupted – try reinstalling it.
  4. Restart PyCharm: Sometimes the IDE needs a fresh start to pick up new interpreters.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 09:12:52