Coding⏱️ 3 min read📅 2026-06-11

How to Fix: Installing Python3 on MacOS using Homebrew has error "Failed to import the site module"

Error fixing Python3 installation on MacOS using Homebrew.

Quick Answer: Try reinstalling python3 and python3.6 separately, or use brew install python@3.6 to install a specific version of Python.

Installing Python3 on MacOS using Homebrew can be challenging, especially when encountering errors like 'Failed to import the site module'. This issue affects users who have tried to reinstall Python3 using Homebrew on Mac OSX El Capitan Version 10.11.6.

The frustration of encountering this error is compounded by the fact that it prevents users from accessing their Python3 installation, making it difficult to complete tasks or projects that rely on this software.

💡 Why You Are Getting This Error

  • The primary reason for this error is due to the deprecation of `brew linkapps` and its inability to work seamlessly with Spotlight using aliases or symlinks. This results in issues with relocating formulae.
  • An alternative reason could be related to the fact that Homebrew formulae do not build 'proper' `.app` bundles, leading to difficulties in linking applications.

🔧 Proven Troubleshooting Steps

Resolving the issue by using `brew cask`

  1. Step 1: Open a terminal and run the command `brew install python` (note: this will install Python3 with Homebrew Cask). This command uses the `cask` method to link applications, which resolves issues related to Spotlight and symlinks.
  2. Step 2: Once the installation is complete, verify that Python3 has been successfully installed by running `python --version`.
  3. Step 3: To ensure that the installation is stable, you can also run `brew link python` to create a symbolic link between Homebrew's Python3 and the system's Python3.

Alternative solution using `brew install python` with specific options (optional)

  1. Step 1: If you encounter issues with `brew install python`, try running the command with the following options: `brew install --cask --force-python python`. This will force the installation of Python3, even if it conflicts with other packages.
  2. Step 2: Keep in mind that this method may lead to instability and should be used with caution.

💡 Conclusion

By using `brew cask` or installing Python3 with specific options, you can resolve the 'Failed to import the site module' error and successfully access your Python3 installation.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions