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

Mac多Python版本管理异常:调用python3.6却返回2.7版本求助

Fixing Python 3.6 Path Issue on macOS

It looks like your /usr/local/bin/python3.6 is either an alias pointing to Anaconda's Python 2.7, or a broken symlink. Let's fix this step by step:

Step 1: Check for Aliases or Shell Functions

First, run this command to see if your shell has an alias overriding python3.6:

type -a python3.6

If you see output like:

python3.6 is aliased to '/Users/User/anaconda/bin/python'

You'll need to remove that alias. Look for lines like alias python3.6='/Users/User/anaconda/bin/python' in your shell config files (.bashrc, .zshrc, .bash_profile, etc.), delete them, then restart your terminal or run source ~/.zshrc (or the relevant file) to apply changes.

If there's no alias, check what /usr/local/bin/python3.6 actually points to:

ls -l /usr/local/bin/python3.6

If the output shows it's linked to Anaconda's Python (e.g., -> /Users/User/anaconda/bin/python), that's the problem. We need to relink it to your actual Python 3.6 installation.

First, remove the incorrect symlink:

sudo rm /usr/local/bin/python3.6

Then create a new symlink pointing to your real Python 3.6 executable. Based on your PATH, it should be in /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6:

sudo ln -s /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /usr/local/bin/python3.6

Step 4: Verify the Fix

Run the command again to confirm it works:

/usr/local/bin/python3.6 --version

You should now see Python 3.6.x instead of 2.7.14.

Optional: Set Python 3.6 as Default (If Needed)

If you want python to point to 3.6 by default, adjust your PATH in your shell config file to put the Python 3.6 directory before Anaconda's. For example, add this line to .zshrc or .bashrc:

export PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:$PATH"

Then restart your terminal or run source ~/.zshrc to apply.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 06:59:06