0

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.

Jupyter Error

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

  1. GDAL 2.4 installed from GIS Internals and Jupyter installed via pip

  2. 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.

  • 2
    When using GIS Internals gdal, make sure you run jupyter from the GIS Internals SDKShell.bat environment. – user2856 Jun 30 at 11:50
  • Why not downloading Anaconda and installing gdal using Conda? It comes with Jupyter Notebook and it works just fine. – Marcelo Villa Jul 1 at 3:55
  • @user2856 I tried this and it raises the same exception. I've also tried starting Jupyter from C:\Program Files\GDAL where the required DLL lives and that also raises the same exception. – Ali Jul 1 at 7:41
  • @MarceloVilla Switching to Anaconda would not solve the "why" of this question. I'm interested in the reason why this is happening. – Ali Jul 1 at 7:49
  • I haven't used GIS Internals gdal for a few years, so can't comment more But one method I've found very useful in tracking down these sort of issues is SysInternals depends.exe – user2856 Jul 1 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.