Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice - Installing GDAL #949

Open
Orsucciu opened this issue Jan 16, 2025 · 0 comments
Open

Advice - Installing GDAL #949

Orsucciu opened this issue Jan 16, 2025 · 0 comments

Comments

@Orsucciu
Copy link

Orsucciu commented Jan 16, 2025

Hi,

I'm unsure if this should be an issue, it's more like a tip.

I've had a lot of problems to install GDAL in a self-contained way for this addon.

I was hit with the terrible .dll error:

`>>> from osgeo import gdal
ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\gdal_FITS.dll
127: The specified procedure could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\gdal_FITS.dll
127: The specified procedure could not be found.`

My solution was to edit the init.py file to this:

`# init for osgeo package.

from sys import version_info
import os

try:
_here = os.path.dirname(file)
os.environ['GDAL_DATA'] = os.path.join(_here, 'data', 'gdal')
os.environ['PATH'] = _here + ';' + os.environ['PATH']
os.environ['PROJ_LIB'] = os.path.join(_here, 'data', 'proj')
os.environ['GDAL_DRIVER_PATH'] = os.path.join(_here, 'gdalplugins')
os.add_dll_directory(_here)
except Exception:
pass

from . import _gdal

version = _gdal.version = _gdal.VersionInfo("RELEASE_NAME")

gdal_version = tuple(int(s) for s in str(version).split('.') if s.isdigit())[:3]
python_version = tuple(version_info)[:3]
`

doing this FORCES python to use the local, self-contained gdal install instead of any system one. It also protects your path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant