Windows下OSGeo4W安装PROJ 4.9.0失败及pip安装Cartopy报错求助
Hey Carl, let’s work through this frustrating Cartopy/PROJ issue step by step—this is a super common headache on Windows, so I’ve got a few tried-and-true fixes that should get you up and running.
It sounds like you might have missed a step or the default OSGeo4W setup isn’t showing the older PROJ version. Try this:
- Re-run the OSGeo4W installer and select the Advanced Install mode (not Express)
- Navigate to the Select Packages screen, then search for
proj- If 4.9.0 doesn’t show up, click the
Viewdropdown in the top-right and switch fromDefaulttoFull—this will display all available versions - Check the box for
proj-devel(not just the base proj package) in version 4.9.0
- If 4.9.0 doesn’t show up, click the
- Repeat the same process for
geos: search for it, checkgeos-devel(Cartopy requires this development package, not just the runtime) - Finish the installation, and note down your OSGeo4W install path (usually
C:\OSGeo4W64for 64-bit systems)
Pip doesn’t automatically detect OSGeo4W’s installed libraries, so you need to point it in the right direction.
Option A: Use the OSGeo4W Shell (easiest!)
The OSGeo4W Shell automatically sets all the required environment variables for you. Just:
- Open the OSGeo4W Shell from your Start menu
- Run
pip install cartopydirectly here—this should pick up PROJ and GEOS without extra work
Option B: Manually set environment variables (for regular CMD/PowerShell)
If you prefer using a regular command prompt, set these variables first:
set PROJ_DIR=C:\OSGeo4W64\share\proj set GEOS_DIR=C:\OSGeo4W64\bin set PATH=%PATH%;C:\OSGeo4W64\bin;C:\OSGeo4W64\lib
Then run pip install cartopy
Option C: Install Cartopy with explicit paths
If environment variables don’t stick, force pip to use your OSGeo4W libraries directly:
pip install cartopy --install-option="--proj-lib=C:\OSGeo4W64\share\proj" --install-option="--geos-dir=C:\OSGeo4W64\bin"
If you still can’t get PROJ 4.9.0 via OSGeo4W, use pre-built Python wheels for PROJ and GEOS:
- Download the correct wheel files for your Python version and system architecture (32/64-bit)
- Install PROJ first, then GEOS:
pip install path\to\proj-4.9.0-cpXX-none-win_amd64.whl pip install path\to\geos-X.X.X-cpXX-none-win_amd64.whl - Then install Cartopy normally with
pip install cartopy
Once you’ve installed everything, test it in Python to make sure it works:
import cartopy import pyproj print(f"Cartopy version: {cartopy.__version__}") print(f"PROJ version: {pyproj.__version__}")
If this runs without errors, you’re good to go!
内容的提问来源于stack exchange,提问作者Carl

