Michael,
--with-python sets the path to the python binary that you want to use and while
that may not intuitively seem like it sets the install path, it actually does.
If you have multiple separate python binaries installed on the system (e.g.
from using virtualenv), generally each one of them has their own separate
site-packages directory and when you tell configure which binary you want to
use, the binary tells configure where to find the appropriate site-packages
directory and where to install gdal.
I did a quick example run of this, just to make sure that I'm right and the
workflow is something like this:
1) Setup your separate python binary with virtualenv (or by some other means)
james@granite:~$ virtualenv python-alt
New python executable in python-alt/bin/python
Installing
distribute.............................................................................................................................................................................................done.
Installing pip...............done.
2a) At this point you might be able to use pip to download/build/install gdal
(you just may not have as much control over the build process)
james@granite:~$ ./python-alt/bin/pip install gdal
Downloading/unpacking gdal
Downloading GDAL-1.9.1.tar.gz (420Kb): 420Kb downloaded
Running setup.py egg_info for package gdal
Installing collected packages: gdal
Running setup.py install for gdal
building 'osgeo._gdal' extension
...
Successfully installed gdal
Cleaning up...
james@granite:~$ ./python-alt/bin/python
Python 2.7.3 (default, Aug 1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gdal
>>> gdal.__file__
'/home/james/python-alt/local/lib/python2.7/site-packages/gdal.pyc'
>>>
2b) Or you can build from the subversion repo
james@granite:~/code/svn/gdal$ ./configure
--with-python=$HOME/python-alt/bin/python --prefix=$HOME
...
james@granite:~/code/svn/gdal$ make
...
james@granite:~/code/svn/gdal$ make install
...
At this point you should have all of the gdal goodies in your python install:
james@granite:~/code/svn/gdal$ ls
~/python-alt/local/lib/python2.7/site-packages/GDAL-2.0.0-py2.7-linux-i686.egg/
EGG-INFO gdalconst.py gdalconst.pyc gdal.py gdal.pyc ogr.py ogr.pyc
osgeo osr.py osr.pyc
james@granite:~/code/svn/gdal$ ls
~/python-alt/local/lib/python2.7/site-packages/GDAL-2.0.0-py2.7-linux-i686.egg/osgeo/
gdal_array.py _gdalconst.pyc gdalnumeric.pyc gdal.pyc _ogr.py
_ogr.so osr.pyc
gdal_array.pyc gdalconst.pyc _gdal.py _gdal.so ogr.py
_osr.py _osr.so
_gdalconst.py _gdalconst.so gdal.py __init__.py _ogr.pyc osr.py
gdalconst.py gdalnumeric.py _gdal.pyc __init__.pyc ogr.pyc
_osr.pyc
...and you should be able to load the gdal module.
james@granite:~/code/svn/gdal$ ~/python-alt/bin/python
Python 2.7.3 (default, Aug 1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
>>> gdal.__file__
'/home/james/python-alt/local/lib/python2.7/site-packages/GDAL-2.0.0-py2.7-linux-i686.egg/osgeo/gdal.pyc'
Hope that helps.
~James
On Fri, Nov 02, 2012 at 01:01:26AM +0000, Michael Speth wrote:
> Greetings,
>
> I am attempting to compile gdal with python support. However, I don't want
> to use the system installed python; I want to use a locally compiled version
> of
> python. I am unable to find how to select the python version to use with the
> gdal install.
>
>
>
> It seems that --with-python doesn't have an option to set the python install
> directory; --with-hdf5 can set the install directory of hdf5.
>
>
>
> Is there a way to set gdal to point to a different install directory for
> python?
>
>
>
> If not, how does gdal find the path to python? Is it possible to set an
> environment variable (I am compiling on GNU/Linux)?
>
>
>
> Thanks
>
>
>
> --
>
> Michael Speth
>
> Research Systems Developer
>
> Landcare Research
>
>
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
>
> Please consider the environment before printing this email
> Warning: This electronic message together with any attachments is
> confidential.
> If you receive it in error: (i) you must not read, use, disclose, copy or
> retain it; (ii) please contact the sender immediately by reply email and then
> delete the emails.
> The views expressed in this email may not be those of Landcare Research New
> Zealand Limited. http://www.landcareresearch.co.nz
> _______________________________________________
> gdal-dev mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev