Skip to content

No module named 'splashkit' in Python error

Problem

MacOS prioritises its built-in Python installation located in /usr/bin/python3. SplashKit and other dependencies are likely installed in the Python environment managed by Homebrew, which is located at /opt/homebrew/bin/python3 or similar. Due to this, the SplashKit module cannot be located in shell’s environment variables (PATH).

Error Example

Solution

To resolve this, add this line: eval "$(/opt/homebrew/bin/brew shellenv)" to your .zshrc file. Follow the steps below:

  1. Locate Your .zshrc File

    The .zshrc file is located in your home directory at ~/Users/(your username)/.

    If you don’t see it, press Shift + Command + . (dot) to toggle hidden files visibility in Finder.

  2. Add ‘homebrew’ path

    To ensure macOS uses the Homebrew-installed version of Python, open the .zshrc file with a text editor and add the following line at the start to include the homebrew path:

    Terminal window
    eval "$(/opt/homebrew/bin/brew shellenv)"
  3. Apply Changes

    Save the .zshrc file and then reload it with the following command to apply changes immediately:

    Terminal window
    source ~/.zshrc
  4. Check Python version

    Verify that the terminal is using the Homebrew-installed Python version:

    Terminal window
    which python3

    The output should be something like:

    Terminal window
    /opt/homebrew/bin/python3
  5. Test the setup

    Run your Python script again. It should now successfully locate the SplashKit module.

After completing these steps, your terminal will use the Homebrew-installed version of Python, and your Python script should now successfully find and run the SplashKit module without encountering the ModuleNotFoundError.