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

python及python3命令未指向pyenv全局版本的问题求助

Fixing pyenv: python: command not found When Using Homebrew-Installed Python Versions

Let's break down why this error pops up and how to fix it quickly:

Why the Error Happens

When you symlinked your Homebrew-installed Python versions into pyenv's versions directory, you might have missed a key detail: Homebrew names Python 3's executable python3 instead of python (unlike Python 2, which uses python by default). Pyenv looks for a python executable in your active global version's bin folder—since 3.6.5 doesn't have one, it checks other installed versions and throws the error pointing to 2.7.15.

Step-by-Step Fix

  1. Confirm the missing executable
    First, check that your 3.6.5 version only has python3:

    ls ~/.pyenv/versions/3.6.5/bin
    

    You’ll see python3 listed, but no python entry.

  2. Create a symlink for python in the 3.6.5 directory
    Link python to python3 so pyenv can locate the command:

    ln -s ~/.pyenv/versions/3.6.5/bin/python3 ~/.pyenv/versions/3.6.5/bin/python
    
  3. Verify the fix
    Run this to confirm the global version is now recognized:

    python --version
    

    It should output Python 3.6.5.

Bonus: Double-Check Pyenv Initialization

If the fix above doesn’t work, make sure pyenv's shims are properly loaded in your shell. Check that ~/.pyenv/shims is at the start of your PATH:

echo $PATH

If it’s not, add these lines to your shell config file (e.g., ~/.bashrc, ~/.zshrc):

export PATH="$HOME/.pyenv/shims:$PATH"
eval "$(pyenv init -)"

Then restart your shell or run source ~/.bashrc (or your specific config file) to apply the changes.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 09:50:38