Quick Mac Installation Guide
This is a simplified installation guide specifically for macOS users.
đ Important: Understanding Python Environments
QGIS has its own Python - itâs completely separate from any other Python on your Mac.
If you have multiple Python installations (Homebrew, Anaconda, system Python), donât worry - they wonât interfere. But you need to install the plugin dependencies specifically into QGISâs Python, not your other Python installations.
Where is QGISâs Python?
- Location:
/Applications/QGIS.app/Contents/MacOS/python3.12 (or python3.11 depending on QGIS version)
- This is different from
/usr/bin/python3 (macOS system Python)
- This is different from
/opt/homebrew/bin/python3 (Homebrew Python)
- This is different from conda/anaconda Python
Why does this matter?
If you accidentally install dependencies to the wrong Python, QGIS wonât be able to find them and the plugin wonât work.
The good news: The installation methods below automatically use the correct Python, so you donât have to worry about it! Just follow the steps. đ
Step 1: Install QGIS
- Download: QGIS for macOS
- Open the
.dmg file and drag QGIS to Applications
- First launch: Right-click QGIS â Open (to bypass security warning)
Step 2: Install Dependencies
â
RECOMMENDED: Use QGIS Python Console
This is the most reliable method because QGIS Python Console automatically uses the correct Python environment - thereâs no way to accidentally use the wrong Python!
Mental model: The QGIS Python Console runs Python only. Terminal commands (anything starting with /Applications/... or QGIS_PYTHON=...) must be run in Terminal, not in the console.
Tip: If you see an error like NameError: name 'QGIS_PYTHON' is not defined, you pasted a Terminal command into the console.
Method 1: Automated Script (Easiest - Just Click Run!)
- Get the script (choose one):
- Download the GeoPublicHealth repository (ZIP or git clone) and unzip it. The script is inside the folder:
install_dependencies_console.py.
- Or download the script directly: https://raw.githubusercontent.com/ePublicHealth/GeoPublicHealth/refs/heads/main/install_dependencies_console.py
- Save the file locally as
install_dependencies_console.py (recommended location: ~/Downloads/).
- Or open the link, copy the full script, paste it into the QGIS Python editor, and save it as
install_dependencies_console.py.
- Open QGIS
- Go to Plugins â Python Console
- Click âShow Editorâ button (toolbar icon)
- Click âOpen Scriptâ and select
install_dependencies_console.py
- If you canât find it, use Cmd+Shift+G and paste the folder path (e.g.
~/Downloads/GeoPublicHealth)
- You can also use Finder search for
install_dependencies_console.py
- Click âRun Scriptâ
- Watch progress messages in the console
- The script automatically:
- Enables âShow also experimental pluginsâ setting
- Adds GeoPublicHealth plugin repository
- Reloads plugin repositories from the network
- Installs required dependencies (libpysal, esda, numba)
- Installs the GeoPublicHealth plugin
- đ Restart QGIS when complete (required for new packages and plugin to load)
- đ§ž Logs: Saved to
~/GeoPublicHealth/ (fallback: /tmp/)
Method 2: Manual Verification (After Automated Script)
After running the automated script (Method 1), verify the installation worked:
- đ Restart QGIS first (required for new packages to load)
- Open QGIS
- Go to Plugins â Python Console
- Run this verification script:
import sys
import libpysal, esda, numba, shapely, geopandas, fiona
print(f"Python: {sys.executable}")
print("(Should contain 'QGIS.app')\n")
print("â All dependencies installed!")
print(f" libpysal {libpysal.__version__}")
print(f" esda {esda.__version__}")
print(f" numba {numba.__version__}")
print(f" shapely {shapely.__version__} (should be 2.1.2+)")
print(f" geopandas {geopandas.__version__}")
print(f" fiona {fiona.__version__}")
What to check:
- Python path should contain
QGIS.app (confirms youâre using QGISâs Python)
- Shapely version should be 2.1.2 or newer (required for libpysal compatibility)
- GeoPandas and Fiona are installed (required for GeoPackage .gpkg file support)
- You should see version numbers for all packages
If verification fails: See Troubleshooting section below or use the automated scriptâs restart prompt.
Alternative Methods (For Advanced Users)
â ď¸ These commands are for Terminal, not the QGIS Python Console. If you paste them into the console, they will fail.
Click to expand Terminal-based methods
**â ď¸ Warning:** These require using the exact QGIS Python path. The console methods above are more reliable.
**Terminal One-Liner:**
â ď¸ **Not recommended** - use the automated console script instead (Method 1). The script handles Shapely/Numba installation correctly with `--target` and `--no-deps` to avoid NumPy 2.x conflicts.
If you must use Terminal:
```bash
# This installs to framework site-packages and may cause version conflicts
/Applications/QGIS.app/Contents/MacOS/python3.12 -m pip install numpy scipy pandas libpysal esda matplotlib --no-build-isolation
```
**Shell Script:**
â ď¸ **Deprecated** - use `install_dependencies_console.py` from QGIS Python Console instead.
```bash
cd /path/to/GeoPublicHealth
bash install_mac_dependencies.sh
```
**For automation / CI / QGIS-LTR:**
```bash
# Non-interactive mode with logging
/Applications/QGIS.app/Contents/MacOS/python3.12 install_mac_dependencies.py --yes --log /tmp/install.log
# Override QGIS path for QGIS-LTR
QGIS_PYTHON="/Applications/QGIS-LTR.app/Contents/MacOS/python3.11" bash install_mac_dependencies.sh
```
Fallback: Install the Plugin Manually
Use these steps only if the automated script did not install the plugin after restarting QGIS.
- Open QGIS
- Go to Plugins â Manage and Install Plugins
- Go to Settings tab
- đ¨ Critical: Check âShow also experimental pluginsâ (the plugin will not appear without this)
- Click Add button:
- Name:
GeoPublicHealth
- URL:
https://raw.githubusercontent.com/ePublicHealth/GeoPublicHealth/main/docs/plugins.xml
- Go to All tab
- Search for
geopublichealth
- Click Install Plugin
Verify Everything Works
đ IMPORTANT: Restart QGIS first! (QGIS only loads packages at startup)
Then open the QGIS Python Console and run:
import sys
import libpysal, esda, numba, shapely, geopandas, fiona
print(f"Python: {sys.executable}")
print("(Should contain 'QGIS.app')\n")
print("â All dependencies installed!")
print(f" libpysal {libpysal.__version__}")
print(f" esda {esda.__version__}")
print(f" numba {numba.__version__}")
print(f" shapely {shapely.__version__} (should be 2.1.2+)")
print(f" geopandas {geopandas.__version__}")
print(f" fiona {fiona.__version__}")
What to check:
- The Python path should contain
QGIS.app (confirms youâre using QGISâs Python)
- Shapely version should be 2.1.2 or newer (QGIS bundles 2.0.6 which is incompatible)
- GeoPandas and Fiona are installed (enables GeoPackage .gpkg file support in autocorrelation)
- You should see version numbers for all packages
If you see version numbers, youâre ready to go! đ
Why the restart matters: QGIS loads Python packages only at startup. After installing dependencies, a full restart is the reliable way to make them available (reloading plugins is not enough).
Why these packages matter:
- Shapely 2.1.2: QGIS bundles 2.0.6, but libpysal requires 2.1.2+ (API breaking changes). The automated script installs 2.1.2 to your QGIS profile directory which overrides the bundled version.
- GeoPandas + Fiona: Required for GeoPackage (.gpkg) file support in autocorrelation analysis. Without these, the plugin falls back to shapefile-only mode.
If it doesnât work:
âModuleNotFoundError: No module named âlibpysalââ
Solutions:
- Did you restart QGIS? This is the most common issue - restart first, then try verification again
- Run the automated script (Method 1) - it handles installation correctly
- Check the installation log file in
~/GeoPublicHealth/ for errors
âImportError: Shapely version 2.1.2+ requiredâ
The automated script installs Shapely 2.1.2 to override QGISâs bundled 2.0.6. If you see this error:
- Ensure you ran
install_dependencies_console.py (not manual Terminal commands)
- Restart QGIS after installation
- Check Shapely version:
import shapely; print(shapely.__version__)
âPermission deniedâ errors
The automated script handles permissions correctly. If you see this:
- Use Method 1 (automated script) instead of Terminal commands
- Or use
--user flag if using Terminal:
/Applications/QGIS.app/Contents/MacOS/python3.12 -m pip install --user libpysal esda numba
Plugin doesnât appear
- Check experimental plugins are enabled (see Step 3)
- Clear cache:
rm -rf ~/Library/Application\ Support/QGIS/QGIS3/profiles/default/cache
- Restart QGIS
Library loading errors
Install XQuartz: https://www.xquartz.org/
Need More Help?
For Advanced Users
If you want to understand:
- Why QGIS has its own Python
- How Python environments work on Mac
- Detailed installation methods and troubleshooting
- Development workflows
See the complete technical guide: MAC_INSTALL_TECHNICAL.md