Well today, I finally succeeded. The following recipe seems to work for GDAL 1.8.1. It assumes that you have virtualenv and the virtualenvwrapper already installed.
(1) Build and install GDAL with Python bindings on your system
GDAL_VER=1.8.1 GDAL_PATH=/usr/local/gdal/$GDAL_VER GEOS_VER=3.2.2 GEOS_PATH=/usr/local/geos/$GEOS_VER mkdir ~/src/gdal cd ~/src/gdal wget http://download.osgeo.org/gdal/gdal-$GDAL_VER.tar.gz tar xzf gdal-$GDAL_VER.tar.gz cd gdal-$GDAL_VER ./configure --prefix=$GDAL_PATH --with-geos=$GEOS_PATH/bin/geos-config --with-python >& log_configure.out make >& log_make.out make install >& log_make_install.out sudo sh -c "echo $GDAL_PATH'/lib' > /etc/ld.so.conf.d/gdal.conf" sudo ldconfig
(2) Create a Python Virtual Environment
mkvirtualenv --no-site-packages osgeo-test
(3) Create a symbolic link from within the virtual environment to gdal-config
This is needed because the setup.py file of the GDAL Python bindings requires gdal-config.# create a symbolic link in the virtual environment to the specific version of GDAL that you want to use (osgeo-test)$ ln -s ~/src/gdal/gdal-1.8.1/apps/gdal-config ~/.virtualenvs/osgeo-test/bin/gdal-config
(4) Download the GDAL Python package using PIP
Download, but don't install, since we need to configure the build extension parameters.(osgeo-test)$ pip install --no-install GDAL
(5) Set the build extension parameters using setup.py
(osgeo-test)$ cd ~/.virtualenvs/osgeo-test/build/GDAL (osgeo-test)$ python setup.py build_ext --gdal-config=/usr/local/gdal/1.8.1/bin/gdal-config --library-dirs=/usr/local/gdal/1.8.1/lib --libraries=gdal --include-dirs=/usr/local/gdal/1.8.1/include
(6) Install the configured package using PIP
(osgeo-test)$ cd (osgeo-test)$ pip install --no-download GDAL
(7) test it out
(osgeo-test)$ cd (osgeo-test)$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from osgeo import gdal >>> gdal.__version__ '1.8.1' >>>
This comment has been removed by the author.
ReplyDeleteJust wanted to add that as of June 2012, pip install GDAL actually seems to work well.
ReplyDeleteIf I try to compile GDAL using the --with-python option, it picks up my system default python (2.4), not the virtualenv, or another version I manually installed. Is there a way to change this?
ReplyDeleteIf using GDAL from repo, it could be you have to use the corresponding gdal-Version. E.g. use $ pip install --no-install GDAL==1.8.1
ReplyDeleteThank you! It's very useful post.
ReplyDeleteI get an error at the last step:
ReplyDeleteerror: command 'x86_64-linux-gnu-gcc' failed with exit status 1
kayseriescortu.com - alacam.org - xescortun.com
ReplyDeleteThanks for every other excellent post. The place else may just anyone get that kind of info in such an ideal manner of writing? I’ve a presentation subsequent week, and I am at the look for such information. https://python.engineering/3930188-how-to-convert-nonetype-to-int-or-string/
ReplyDeletemmorpg
ReplyDeleteInstagram takipçi satın al
Tiktok jeton hilesi
tiktok jeton hilesi
antalya saç ekimi
referans kimliği nedir
instagram takipçi satın al
metin2 pvp serverlar
takipci satin al
smm panel
ReplyDeletesmm panel
İs İlanlari Blog
İNSTAGRAM TAKİPÇİ SATIN AL
HİRDAVATCİ BURADA
beyazesyateknikservisi.com.tr
SERVİS
jeton hile