However GDAL is installed correctly and the header file is located at /usr/include/gdal/cpl_port.h. Is there some environment variable for GDAL that needs to be set in order for pip to find the header files?

Requirements

Installation methods

There are multiple methods for installation. One requires compilation
and takes few minutes more.

The other is using wheel package of pygdal package and is very quick.
Anyway, to create the wheel package one needs to create it once and the creation includes the compilation step anyway.

About GDAL packages and versions

GDAL is general C(++) based library for GEO related calculations.

GDAL utilities can be installed system wide what makes shared libraries
available, but does not install Python package itself.

GDAL comes in different versions and each Linux distribution may by
default install different version.

Python package gdal requires compilation and is not trivial to install
on Linux based systems as it expects few environmental variables to be
set. This makes installation into virtualenv more difficult.

Each gdal version might assume different version of GDAL and will fail
installing if expected version is not present in the system.

Python package pygdal is alternative to gdal, which installs exactly the
same stuff as gdal, but does it in much more virtualenv friendly manner.

pygdal comes in versions reflecting related GDAL version. So having GDAL
version 1.10.1 in the system you shall install pygdal version 1.10.1.

Python package gdal (as well as pygdal) uses root python package named
osgeo and has set of submodules, one being osgeo.gdal.

If needed, other than default versions of GDAL can be installed and
used. This is out of scope of this description.

Wheel packages can be cross-compiled, this is also out of scope.

Installing GDAL into system

As pygdal requires GDAL shared libraries to be present, we must install
them first.

Assuming GDAL is not yet installed, calling gdal-config will complain
and give you a hint how to follow up:

$ gdal-config --version
The program 'gdal-config' is currently not installed. You can install it by typing:
sudo apt-get install libgdal-dev

Follow the hint and install it:

$ sudo apt-get install libgdal-dev

Each distribution may use different version of GDAL. To find out which
we use:

$ gdal-config --version
1.10.1

Now you know, GDAL is installed and the version is 1.10.1 (the version
can vary).

Install pygdal from source package (requires compilation)

Currently pygdal is provided only in tar.gz package, which contains
package sources and requires compilation.

Assuming, the version of GDAL is 1.10.1 and that our virtualenv is
already activated:

$ pip install pygdal==1.10.1

It may take a while to complete, is it needs numpy, which may also
require some compilation. Just wait.

Check, it is installed:

$ pip freeze|grep pygdal
pygdal==1.10.1.0

From now on, you may use osgeo package in your Python code as you like
in exactly the same manner as if you would install it by gdal Python
package.

Creating wheel package for pygdal

Note, that wheel packages must be created for exactly the same
architecture, namely must match:

CPU architecture

OS (Linux/Windows)

In our case, it must also match the version of GDAL installed.

Following steps can be done in virtualenv or not, as you like.

First, make sure, wheel package is installed:

$ pip install wheel

Assuming, you have GDAL installed and it has version 1.10.1:

$ pip wheel pygdal==1.10.1.0

and wait, until it completes.

After this, you shall find subdirectory wheelhouse and it shall contain
packages with extension `whl`:

this anwser builds on other great answers here, tries to give complete instructions for the details, where I got stuck and adds steps for using wheel package format for speeding up repeated installs into virtualenv.
–
Jan VlcinskyDec 4 '14 at 9:52

Τhe header files cannot be found for some reason. Maybe you you are operating inside a Virtual Enviroment or they are not where they should be for some reason. In any case you can specify the include dirs when installing gdal via pip.

@nickves I am trying to install GDAL using virtualenvwrapper in Ubuntu, and when I try your first line: pip install --no-install GDAL, I get the error: __main__.gdal_config_error: [Errno 2] No such file or directory Any idea?
–
theJollySinMar 23 '13 at 18:36

Yes, It seems that gdal bindings are trying to find gdal-confing within your virtualenv, and it fails because it's not there. A possible solution (I haven't test it!) is to create a symbolic link of your gdal-config to your virtualenv directory ( ls -s /path/to/gdal/gdal-config /path-to-virtualenvs/your-env/bin/gdal-config ).
–
nickvesMar 25 '13 at 18:50

Very good. In case, installed version of GDAL in system and python package differs, it fails. The solution is to find version of GDAL in system and instruct pip to install relevant python package version. In my case (Ubuntu 14.04) both are 10.0, so it helped $ pip install GDAL==10.0
–
Jan VlcinskyDec 3 '14 at 22:17

The problem with the pip installing gdal is that it only gets the bindings, not the entire library, so it can get tricky. One way to solve it is to use the pip command to download - but not install. Then you tweak the header location from the config file. Then you pip install that. meh.