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

Ubuntu16.04+Python2.7.12环境下用pip安装GDAL失败求助

Fixing GDAL/osgeo Installation Failures on Ubuntu 16.04 + Python 2.7

Hey there, I’ve dealt with this exact GDAL installation headache on Ubuntu 16.04 with Python 2.7 before—let’s break down what’s going wrong and how to fix it.

First, a quick clarification: the osgeo package doesn’t exist as a standalone PyPI package—it’s part of the GDAL (Geospatial Data Abstraction Library) Python bindings. So installing the correct GDAL package will automatically give you access to osgeo.gdal and related modules like gdalconst.

The error you’re seeing (__main__.gdal_config_error: [Errno 2] No such file or directory) happens because pip can’t find the system-level GDAL development files it needs to build the Python bindings. Here’s how to fix it step by step:

Step 1: Install System-Level GDAL Dependencies

First, update your system packages and install the core GDAL libraries and development headers—these are mandatory for the Python package to build correctly:

sudo apt-get update
sudo apt-get install gdal-bin libgdal-dev

Step 2: Match GDAL Versions (Critical!)

Pip’s GDAL package version must match the system-level GDAL version you just installed. First check your system’s GDAL version:

gdal-config --version

In your error log, you’re trying to install GDAL 2.2.3—so assuming your system now has that version, install the matching Python package. First, upgrade your outdated pip (you’re on 7.1.0, which can cause compatibility issues):

pip install --upgrade pip

Then install the matching GDAL version:

pip install GDAL==2.2.3

Step 3: Verify the Installation

Open a Python shell and test the imports to make sure everything works:

from osgeo import gdal
from osgeo.gdalconst import *

If you don’t get any errors, you’re good to go!

Your Original Error Log for Reference

Command "python setup.py egg_info" failed with error code 1 in /tmp/pycharm-packaging347/gdal/
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

内容的提问来源于stack exchange,提问作者A.nechi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 03:25:52