I am trying to export a GeoTiff with Blender using the Blender Python API (based on Python 3), so I've decided to install GDAL on Ubuntu (14.04). What I would like is to get the module as a standalone folder that I could put in the modules directory of Blender (/home/user/.config/blender/2.73/scripts/modules).
The thing is I've run through several different problems trying to install GDAL. I've tried to install from source (for GDAL 2.0.0) here : Official PyPi Gdal
- I ran
sudo apt-get install libgdal-dev gdal-bin
(I list it here because it may be important) - When I am in the extracted GDAL folder, using
python setup.py build & python setup.py install
, the library installs to/usr/local/lib/python2.7/dist-packages/osgeo
. However, when I runpython
from command line, runningfrom osgeo import osr
returnsImportError: No module named _gdal
- Following GDAL via pip , I used pip (
pip install GDAL
) to install the library, and the folder it went to was/usr/lib/python3/dist-packages/osgeo
(usingpip show ...
). Again, runningpython3
and trying to import results in the same error. Of course, when I copy-paste each folder in the blender module directory, I get the same error in the Blender Python console. - So I decided to compile the sources using
./configure --with-python & make & make install
in the source folder. I then copied the folderGDAL-x.x.x/build/lib.linux-x86_64-3.4/osgeo
to the blender modules directory and got this time the error when importing :ImportError: /home/yvesu/.config/blender/2.73/scripts/modules/osgeo/_gdal.so: undefined symbol: _Py_ZeroStruct
. - Trying to compile with python3 using
python3 setup.py build
returns the errorerror: command 'x86_64-linux-gnu-gcc' failed with exit status 1
EDIT 1:
I think I've found the solution : I went to the directory swig/python
(not found in a GDAL-1.11.0 folder but gdal-1.11.0 fodler, can't remember where I downloaded it from), ran python3 setup.py build & python3 setup.py install
and could finally find the folder in /usr/local/lib/python3.4/dist-packages/GDAL-1.11.0-py3.4-linux-x86_64.egg/osgeo
. When I put this osgeo folder oni the Blender modules directory, I was able to import osgeo in Blender. I will report if anything went wrong.
I think I've listed all my attempts at installing GDAL on Ubuntu. Can anyone point me in the right direction? Do you think it is even possible to install it as a standalone module, or do I need linked libraries through LD_LIBRARY_PATH?
Here is the solution I've found :
Download Gdal sources (v2.0.0 is the current stable release) from ftp://ftp.remotesensing.org/gdal/2.0.0/ or http://download.osgeo.org/gdal/2.0.0/ and untar
Go to the directory gdal2.0.0/swig/python
Run python3 setup.py build & python3 setup.py install
Finally find the module folder in, on Ubuntu : /usr/local/lib/python3.4/dist-packages/GDAL-2.0.0-py3.4-linux-x86_64.egg/osgeo
I can now use it in Blender (copying in the modules directory)