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

MacOS Sierra下Python 3.6.4 Tcl/Tk不稳定问题及版本清理求助

Hey there, let's work through this step by step to get you set up with Python 3.6.4, remove the old 3.6.3, and fix that annoying Tcl/Tk instability issue so you can run Pygame smoothly.

Step 1: Remove Python 3.6.3 from your system

First, we need to figure out how Python 3.6.3 was installed—different methods require different uninstall steps.

Check the installation path of Python 3.6.3

Open your terminal and run these commands to confirm the version and its location:

python3 --version
which python3

This will tell you exactly where 3.6.3 is installed, so we can target the right files.

If Python 3.6.3 was installed via Homebrew

Homebrew keeps its packages in a standard location, so uninstalling is straightforward:

brew uninstall python@3.6

Then clean up any leftover files to keep your system tidy:

brew cleanup

If Python 3.6.3 was installed from python.org

Python.org installs frameworks in a dedicated directory. Run these commands to remove it completely:

# Delete the framework directory
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.6

# Remove associated executable files (adjust paths if yours differ)
sudo rm /usr/local/bin/python3.6
sudo rm /usr/local/bin/pip3.6
sudo rm /usr/local/bin/idle3.6
Step 2: Set Python 3.6.4 as your default terminal Python

Now we need to make sure the terminal uses your 3.6.4 installation by default.

First, find the path to your 3.6.4 installation:

which python3.6

You’ll get a path like /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 (for python.org builds) or /usr/local/bin/python3.6 (if you switch to Homebrew later).

Update your shell configuration file

Depending on which shell you use (Sierra defaults to Bash), edit the right config file:

  • For Bash: Open ~/.bash_profile with a text editor like nano:
    nano ~/.bash_profile
    
  • For Zsh (if you’ve switched to it): Edit ~/.zshrc instead:
    nano ~/.zshrc
    

Add this line to the file, replacing the path with the one you found earlier:

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

This tells your terminal to prioritize this Python version over any others.

Save the file (in nano, press Ctrl+O, hit Enter, then Ctrl+X to exit) and apply the changes:

source ~/.bash_profile  # For Bash users
# OR
source ~/.zshrc         # For Zsh users

Verify it worked by running:

python3 --version

It should now show 3.6.4.

Step 3: Fix the "Tcl/Tk may be unstable" error

The problem here is that python.org’s Python builds often rely on macOS Sierra’s outdated system Tcl/Tk (version 8.5, which is no longer well-supported). Here are two solid fixes:

Homebrew compiles Python with a newer, compatible Tcl/Tk version, which eliminates the instability entirely. Here’s how to set it up:

  1. If you want a clean slate, uninstall your current python.org 3.6.4:
    sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.6
    sudo rm /usr/local/bin/python3.6 /usr/local/bin/pip3.6
    
  2. Install Python 3.6 via Homebrew:
    brew install python@3.6
    
  3. Update your shell config to use Homebrew’s Python (replace the earlier PATH line with this):
    export PATH="/usr/local/opt/python@3.6/bin:$PATH"
    
  4. Source your config file again and verify the version.

Option 2: Update Tcl/Tk manually for python.org Python

If you prefer to stick with the python.org build:

  1. Download the latest compatible ActiveTcl 8.6 release for macOS Sierra from the ActiveState website (make sure to pick the version that supports Sierra).
  2. Install ActiveTcl following the installer prompts.
  3. Reinstall Python 3.6.4 from python.org—the installer will detect the new Tcl/Tk version and use it instead of the system’s outdated one.
Step 4: Install Pygame and test it

Once you have a stable Python 3.6.4 setup, install Pygame using pip:

pip3 install pygame

To confirm everything works, create a simple test script named test_pygame.py:

import pygame
pygame.init()
screen = pygame.display.set_mode((400, 300))
pygame.display.set_caption("Pygame Test")
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
pygame.quit()

Run it with:

python3 test_pygame.py

If a small window pops up without errors, you’re all set to start coding with Pygame!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 08:20:12