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.
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
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_profilewith a text editor like nano:nano ~/.bash_profile - For Zsh (if you’ve switched to it): Edit
~/.zshrcinstead: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.
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:
Option 1: Switch to Homebrew-installed Python 3.6.4 (Recommended)
Homebrew compiles Python with a newer, compatible Tcl/Tk version, which eliminates the instability entirely. Here’s how to set it up:
- 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 - Install Python 3.6 via Homebrew:
brew install python@3.6 - Update your shell config to use Homebrew’s Python (replace the earlier
PATHline with this):export PATH="/usr/local/opt/python@3.6/bin:$PATH" - 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:
- Download the latest compatible ActiveTcl 8.6 release for macOS Sierra from the ActiveState website (make sure to pick the version that supports Sierra).
- Install ActiveTcl following the installer prompts.
- 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.
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

