5

I am having some trouble with GDAL (v2.1-dev). I build it from source today using Poppler and OpenJPEG. All the command line utilities work fine, but none of the Python plugins work at all, producing this error message:

Traceback (most recent call last):
  File "/usr/local/bin/gdal_merge.py", line 37, in <module>
import gdal
  File "/usr/local/lib/python2.7/dist-packages/gdal.py", line 2, in <module>
from osgeo.gdal import deprecation_warn
  File "/usr/local/lib/python2.7/dist-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: libgdal.so.20: cannot open shared object file: No such file or directory

Now, I've seen plenty of threads that say update LD_LIBRARY_PATH or include /usr/local/bin/ in my ld.so.conf file. I've done both of those things and they don't help. Furthermore, those posts all refer to libgdal.so.1 not being found. So, I added the location of libgdal.so.20 to ld.so.conf and still no dice.

Any recommendations?

Update (11/2/15)
I am running Ubuntu 14.04.03 32bit, cleanly installed just a few days ago.
I followed these instructions to download, make, and install GDAL and OpenJPEG in a folder I made called /home/ronn4031/src/.

0

2 Answers 2

6

Did you do ldconfig to be sure that your changes to LD_LIBRARY_PATH are really applied?

Where is your libgdal.so.20 file?

Did you look at the GDAL .travis.yml file? A Travis file instructs how you can compile, deploy code for testing. It's firstly for testing code purpose but you can also use it to find out if you didn't miss a point when compiling.

Edit

It seems that you are missing parts otherwise, it would works. You will find below what I tried to make things work on an Ubuntu box 14.04 (mainly extracted from the .travis.yml file)

wget http://s3.amazonaws.com/etc-data.koordinates.com/gdal-travisci/install-openjpeg-2.0.0-ubuntu12.04-64bit.tar.gz
tar xzf install-openjpeg-2.0.0-ubuntu12.04-64bit.tar.gz
sudo cp -r install-openjpeg/include/* /usr/local/include
sudo cp -r install-openjpeg/lib/* /usr/local/lib

cd ~/$HOME
git clone https://github.com/OSGeo/gdal.git
cd gdal/gdal
./autogen.sh
# I use a prefix because I don't want to mix this compiled version with my already GDAL versions installed 
./configure --with-python --with-poppler --with-openjpeg=/usr/local --prefix=/usr/local/gdal
make
make install
ldconfig

# Temporary: you have to make them persistent or remove the prefix option in configure I used
export LD_LIBRARY_PATH="/usr/local/gdal/lib:$LD_LIBRARY_PATH"
export PATH="/usr/local/gdal/bin:$PATH"
export PYTHONPATH="/usr/local/gdal/lib/python2.7/site-packages/:$PYTHONPATH"

Launch Python with python and do the following to try if it's working:

from osgeo import gdal
print gdal.VersionInfo() # Should return 2010000 currently (may change with time)

I also tried gdal_merge.py and it works too (the initial issue you raised)

7
  • Yes, I have run ldconfig so that it's properly updated. My libgdal.so.20' file is located in /home/ronn4031/src/gdal/.libs/libgdal.so.20` and as for the .travis.yml I can't find it. Suggestions on where to look?
    – nronnei
    Commented Nov 1, 2015 at 2:30
  • Follow the link in my main answer by clicking on the text ".travis.yml"! For the libgdal.so.20, you should also have it in /usr/local/lib/ or /usr/lib and not only in /home/ronn4031/src/gdal/.libs/libgdal.so.20 (it's the place before you make the make install not the definitive place normally).
    – ThomasG77
    Commented Nov 1, 2015 at 2:48
  • Okay so I copied libgdal.so.20 into /usr/local/lib (where libgdal.so is and the directory definitely included in ld.so.conf) with no success, which didn't really surprise me. I followed the ".travis.yml" link right after I posed, realized it was a link. I can't find it in my gdal folder with either locate or ls -a. Why would that be?
    – nronnei
    Commented Nov 1, 2015 at 5:46
  • You should avoid copying files like that without understanding the "why". It's not the way to deploy a compiled version (for GDAL at least). For the "missing" .travis.yml, the question is where did you download the code you are compiling?
    – ThomasG77
    Commented Nov 1, 2015 at 16:47
  • I know I should understand why I am doing things, and I'm sure that was a bad practice but I was in a bind for time (working on a school project). I was able to use gdalwarp to put my rasters together, though, so it's all good. I downloaded the files to /home/ronn4031/src/ (folder I created) and followed these instructions to build and install. Can you point me to any resources that might help me understand the best practice for building from source?
    – nronnei
    Commented Nov 2, 2015 at 18:00
1

I had the same problem on Ubuntu 14.04 LTS with python 3.5.2 |Anaconda after installing via "conda install gdal". I searched for libgdal.so.20 on my computer, but it was nowhere. I then first did a "conda install libgdal" and then "conda install gdal". This fixed the problem for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.