Below is a bash session, in a docker container running GDAL docker/ubuntu-small. In the container in 'builder' mode I've run
cmake .. -DCMAKE_BUILD_TYPE=Debug
sudo cmake --build . --target install
I start python3, which is 3.10.6 - and GDAL has placed the osgeo libs into '/usr/local/lib/python3/dist-packages', but python is only looking in '/usr/local/lib/python3.10/dist-packages'
Is there a config step with cmake, or a subsequent step with python config that I should be doing? (do I just symlink the libs??)
root@53837d4fa20e:/gdal-source/build2# python3
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'osgeo'
>>>
[3]+ Stopped python3
ls /usr/lib/python3/dist-packages/
_distutils_hack numpy numpy-1.21.5.egg-info pkg_resources setuptools setuptools-59.6.0.egg-info
ls /usr/local/lib/python3/dist-packages/
GDAL-3.7.0.egg-info osgeo osgeo_utils
python3
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/usr/local/lib/python3.10/dist-packages', '/usr/lib/python3/dist-packages']
>>>
Details above were posted to back up this question on gdal-dev: https://lists.osgeo.org/pipermail/gdal-dev/2023-March/057000.html
The answer is to not use the implicit value for CMAKE_INSTALL_PREFIX which is /usr/local, set it to /usr:
thanks Even Rouault https://lists.osgeo.org/pipermail/gdal-dev/2023-March/057001.html
all working now without extra cruft. For reference we can do the implicit one
cmake .. ; cmake --build . etc
by following up withbut then you have extra stuff going on so let's avoid it