1

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.

asked Jun 29, 2019 at 18:39
6
  • 2
    When using GIS Internals gdal, make sure you run jupyter from the GIS Internals SDKShell.bat environment. Commented Jun 30, 2019 at 11:50
  • Why not downloading Anaconda and installing gdal using Conda? It comes with Jupyter Notebook and it works just fine. Commented Jul 1, 2019 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. Commented Jul 1, 2019 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. Commented Jul 1, 2019 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 Commented Jul 1, 2019 at 8:03

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.