[gdal-dev] question about python installation

Michael Sumner mdsumner at gmail.com
Tue Mar 7 18:45:12 PST 2023


Ah, awesome - thanks as ever for such great detail.

I've been trying with PYTHONPATH and sys.path, and I think I was doing it
wrong ...   but the simplicity of the /usr prefix had not occurred to me,
I'll be doing that.

If I come back around with further insights I'll share them, but this is
working for me now.

cmake .. -DCMAKE_INSTALL_PREFIX=/usr

Cheers, Mike





On Wed, Mar 8, 2023 at 1:35 PM Even Rouault <even.rouault at spatialys.com>
wrote:

> Michael,
>
> My experience is that understanding how and where to install Python stuff
> is utterly difficult. And this is even more complicated on Debian/Ubuntu
> that have many patches regarding sys.path and distutils, plus the fact that
> distutils is deprecated and going to be removed in Python 3.12, without a
> clear replacement. Just look at all the horrible logic in
> swig/python/CMakeLists.txt from line 428 to 504 +
> swig/python/trimmedsysconfig.py + swig/python/install_python.cmake.in.
> Perhaps there's a better way...
>
> GDAL hopefully does the right thing for a typical distribution
> installation where CMAKE_INSTALL_PREFIX=/usr . For other prefixes, such as
> the implicit /usr/local prefix, you're on your own, and you will likely
> have to set the PYTHONPATH environment variable to point to
> /usr/local/lib/python3/dist-packages
>
> GDAL_PYTHON_INSTALL_PREFIX will not help you here (and I'm not sure to
> remember what the actual use case for it was)
>
> Even
> Le 08/03/2023 à 02:19, Michael Sumner a écrit :
>
> Hello, apologies as this is not so much a GDAL but a python question, but
> I'm interested in what others do, hopefully I'm missing a key step that's
> not hacky :)
>
> I made a gist to record the details:
>
> https://gist.github.com/mdsumner/526af876cfddaa5ff245ab376b3cec84
>
> The crux is,  GDAL has placed the python osgeo lib files into
> '/usr/local/lib/python3/dist-packages', but python is only looking in
> '/usr/local/lib/python3.10/dist-packages' (as seen in sys.path).
>
> Is there a config step with cmake, or a subsequent step with python config
> that I should be doing?
>
> Is it GDAL_PYTHON_INSTALL_PREFIX ?
>
> Thank you.
>
>
> --
> Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> Hobart, Australia
> e-mail: mdsumner at gmail.com
>
> _______________________________________________
> gdal-dev mailing listgdal-dev at lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/gdal-dev
>
> -- http://www.spatialys.com
> My software is free, but my time generally not.
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>


-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsumner at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230308/5c0b979f/attachment-0001.htm>


More information about the gdal-dev mailing list