I've been trying to put together some Jupyter Notebooks which demonstrate some GDAL functionality but when I do from osgeo import gdal
I get ImportError: DLL load failed: The specified procedure could not be found.
GDAL imports with no issues using my regular Python environment so I'm wondering what is preventing this import in the Jupyter environment.
I have verified, in both my Python environment and the Jupyter environment, that the sys.path
items are similar and also that osego.__init__
successfully finds the _gdal.pyd
file. The failure for Jupyter is when it tries to load this file using the imp
module's load_dynamic
function.
I have found a couple of related questions on this site and on Stack Overflow. This question remains unanswered, this one fails for a different reason, and this one from SO has some solutions for the Anaconda distrubtion.
I'm running Windows 10 with Python 3.7. and have yet to find an authoritative answer to this so would like to know if anybody has had the same issue and resolved it.
UPDATE
I have tested this on two install methods
GDAL 2.4 installed from GIS Internals and Jupyter installed via pip
Pipenv install of GDAL 2.4 and Jupyter
Method 1 results in the error described above, whilst method 2 works successfully.
In the site-packages\osgeo
folder the pipenv-installed version includes the gdal204.dll
file that _gdal.pyd
loads. Using the GIS Internals installers this dll is in C:\Program Files\GDAL
. This directory is on my PATH
environment variable and the DLL search order on windows will look in the PATH
directories. It therefore seems that Jupyter is not following this search order.
gdal
using Conda? It comes with Jupyter Notebook and it works just fine.C:\Program Files\GDAL
where the required DLL lives and that also raises the same exception.