Python Gdal 2.1 Installation on Ubuntu 16.04

CartoDB installation on ubuntu 16.04 gdal compile error

This is probably because you are missing libgdal-dev (found through ubuntu package content search).

When ever you install a package with hard coded C dependecies you should make sure you have the build-dependencies.

I guess I should get gdal version 1.10.0 ? but how to do that in
ubuntu...

If you followed this step:

sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update

You will get a later version of GDAL.

Never the less, you should install the build dependency, libgdal-dev with sudo apt-get install libgdal-dev, the repeat pip install --no-use-wheel -r python_requirements.txt, if you get more errors, look for the missing header file in the ubuntu packages content search pages, install the package and repeat until complete.

You should also pass the paths to pip:

export CPLUS_INCLUDE_PATH=/usr/include/gdal

export C_INCLUDE_PATH=/usr/include/gdal

pip install --no-use-wheel -r python_requirements.txt

GDAL libraries, who does what

Every piece of info is available, if one is willing to search for it.

  • DEBs (installed system-wide):

    1. gdal-bin ([Ubtu]: Package: gdal-bin) - a collection of gdal related binaries (tools and utilities)
    2. python3-gdal ([Ubtu]: Package: python3-gdal) - Python 3 bindings, extensions (.sos) and some wrapper scripts, which enable gdal usage from Python
    3. python-gdal - the same thing, but for Python 2 (totally unrelated to previous item)
  • WHLs (installed as Python modules to the interpreter used to launch pip):


    1. GDAL ([PyPI]: GDAL) - the sources (.tar.gz) for #2. (and / or #3.). During pip install phase, they are built and installed for current Python
    2. pygdal ([PyPI]: pygdal) - same thing (but for VEnv?) as previous item. It seems to be a lighter version (it doesn't contain the scripts)

But, all of the above depend on libgdal ([Ubtu]: Package: libgdal1i), which is the gdal library.

How to pip install GDAL on Python 3.6 venv

I've finally fixed the problem, and these are the steps I followed:

  1. I uninstalled wheel from my venv

  2. Then I pip installed gdal on the venv to check what error would appear

  3. A wall of error text appeared, in which somewhere I noticed the 'x86_64-linux-gnu-gcc' failed with exit status 1

  4. I typed sudo apt-get install python3.6-dev to install missing packages, as the solution suggests here

  5. Then I ran pip install GDAL=<version that appears on ogrinfo --version> and it worked

Error while installing GDAL

Check that you installed GDAL using this command

gdal-config --version

Then run this commands:

pip download="some_path" GDAL
cd some_path
tar -xvzf GDAL-<version>.tar.gz
cd GDAL-<version>
python setup.py build_ext --include-dirs=/usr/include/gdal/
python setup.py install

Updating from Python 3.5.2 to Python 3.8 using deadsnakes PPA is not working on Ubuntu 16.04 LTS

My ubuntu did not have the latest pre-built packages so I had to install from source according to the following guide: here.

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
tar -xf Python-3.8.0.tgz
cd Python-3.8.0
./configure --enable-optimizations
make -j 8
sudo make altinstall


Related Topics



Leave a reply



Submit