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
).
Solution
To resolve this, add this line: eval "$(/opt/homebrew/bin/brew shellenv)"
to your .zshrc
file. Follow the steps below:
-
Locate Your
.zshrc
FileThe
.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.
-
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: -
Apply Changes
Save the
.zshrc
file and then reload it with the following command to apply changes immediately: -
Check Python version
Verify that the terminal is using the Homebrew-installed Python version:
The output should be something like:
-
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
.