[gdal-dev] question about python installation

Even Rouault even.rouault at spatialys.com
Tue Mar 7 18:34:55 PST 2023


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 list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230308/02f7380d/attachment.htm>


More information about the gdal-dev mailing list