0

I am trying to use a specific package called rasterio in python which I have been unable to use. What I am specifically confused about is the disconnect I am seeing between Windows Command Prompt, Anaconda Prompt, and Jupyter Notebook, the platform I use for python.

I open Jupyter Notebook and run import rasterio and get an error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-17-350e27267e59> in <module>
----> 1 import rasterio

~\Anaconda3\lib\site-packages\rasterio\__init__.py in <module>
     15 from pathlib import Path
     16 
---> 17 from rasterio._base import gdal_version
     18 from rasterio.drivers import driver_from_extension, is_blacklisted
     19 from rasterio.dtypes import (

ImportError: DLL load failed: The specified module could not be found.

I then try to run in Anaconda Prompt (Anaconda3) after running python: and get basically the same error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\MyName\Anaconda3\lib\site-packages\rasterio\__init__.py", line 17, in <module>
    from rasterio._base import gdal_version
ImportError: DLL load failed: The specified module could not be found.

But then I try with Windows Command Prompt, running python and then import rasterio, and the package imports successfully.

And then I notice that running python on Anaconda Prompt shows:

Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

And running python_version() in Jupyter Notebook produces:

'3.7.4'

And then I see running python in Windows Command Prompt shows:

Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32

And so it seems like python in Windows Command Prompt is just in a totally different space than what is being run on Jupyter Notebook and Anaconda Prompt. For some reason rasterio installed successfully with Python 3.9.5 but not with Python 3.7.4. And so while I have been struggling to get rasterio to install correctly, it looks like I already have installed it successfully. But my question is how can I get Jupyter Notebook to "talk" to my python version from Command Prompt so that it "understands" I already installed this package? I simply just want to use this package in Jupyter Notebook, but it just seems like Jupyter Notebook does not understand that it is already installed.

  • It seems to be a problem with the PATH environment setting. Did you install with pip when you installed rasterio? Install using conda from Anaconda Prompt. – Urban87 Dec 03 '21 at 06:40
  • Yes, when I used pip within Command Prompt to install rasterio, which let it install fine. However, installing rasterio via conda from Anaconda Prompt has turned into a lost cause almost. I detailed it in this post here: https://gis.stackexchange.com/questions/417733/unable-to-import-python-rasterio-package-even-though-it-is-installed?noredirect=1#comment680243_417733 – LostinSpatialAnalysis Dec 03 '21 at 06:45
  • Hmmm, try the following. https://stackoverflow.com/questions/55596662/rasterio-and-gdal-dll-load-fail-in-pycharm – Urban87 Dec 03 '21 at 07:23

0 Answers0