You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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.

Fix 1: Install PROJ 4.9.0 and GEOS via OSGeo4W (the correct way)

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 View dropdown in the top-right and switch from Default to Full—this will display all available versions
    • Check the box for proj-devel (not just the base proj package) in version 4.9.0
  • Repeat the same process for geos: search for it, check geos-devel (Cartopy requires this development package, not just the runtime)
  • Finish the installation, and note down your OSGeo4W install path (usually C:\OSGeo4W64 for 64-bit systems)
Fix 2: Make pip recognize your OSGeo4W libraries

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 cartopy directly 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"
Fix 3: Fallback to pre-built wheels (if OSGeo4W fails entirely)

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
Verify your setup

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:40:39