6

When I am importing RASTERIO then i am getting an error as:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import rasterio
  File "C:\Python27\lib\site-packages\rasterio\__init__.py", line 17, in <module>
    from rasterio._base import eval_window, window_shape, window_index
ImportError: DLL load failed: The specified module could not be found.

On importing FIONA i am getting error as:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import fiona
  File "C:\Python27\lib\site-packages\fiona\__init__.py", line 78, in <module>
    from fiona.collection import Collection, BytesCollection, vsi_path
  File "C:\Python27\lib\site-packages\fiona\collection.py", line 7, in <module>
    from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: DLL load failed: The specified module could not be found.

While both rasterio and fiona installed successfully by pip install. please help some one i am stucked here.i am using python 2.7 and gdal1.10 and numpy1.10.2 on 32 bit

3 Answers 3

3

In Windows, you cannot install rasterio an fiona wit pip, why ?

Because they need the compilation of many C libraries and Windows has no compiler by default as in Linux or Mac OS X (see How can I install pyproj into arcpy?)

Therefore you can't install these module with setuptools , easy_install or pip -> DLL load failed: The specified module could not be found.

Use the Christoph Gohlke's compiled versions fiona and rasterio

5
  • Can be done with pip if the MS Visual C++ compiler for python is installed, but installing via Christoph Gohlke's versions is definitely easier.
    – user2856
    Mar 11, 2016 at 11:00
  • 1
    i have installed MS visual C++ compiler for python even then i am getting same error. now i extracted pypi rasterio tar file as rasterio-0.27.0 and when i am installing it by python setup.py install then it is giving error as -rasterio/_base.c(263): fatal error c1083: canot open include : cpl_conv.h':no such file or directory and cl.exe failed with exit status 2 Mar 11, 2016 at 16:34
  • Have you installed the GAL/OGR Python module because cpl_conv.h is part of GDAL
    – gene
    Mar 12, 2016 at 10:33
  • yes i have installed gdal ogr via exe file. i resolved cpl_conv.h( and other header file problem) by copying required header file in microsoft visual C++ for python's include folder but now after cl.exe got all the header files i got a new problem thatis- link .exe failed with exit status 1120. and fatal error LINK1120: 42 unresolved externals Mar 13, 2016 at 8:30
  • Sorry but I don't work on Windows and I cannot help you
    – gene
    Mar 13, 2016 at 9:37
2

I'd say gene's answer works for the vast majority of the cases and I use Gohlke's wheel files quite often. However, if you have a custom GDAL (or are just really set on doing it yourself), and you've got the MS C++ compiler, you can build rasterio from source on Windows.

One thing that might be hanging you up is that you'll probably need to specify a couple extra options in the setup.cfg file. I did this:

[build_ext]
include_dirs=C:\path\to\gdal\include\dir
library_dirs=C:\path\to\gdal\lib\dir
libraries=gdal_i

Once you've done that, you should be able to run python setup.py bdist_wheel and then you'll have a wheel file in the dist directory. From there, you can pip install C:\path\to\wheel\file.whl.

0

You can download rasterio, fiona and GDAL wheel file based on your python version from https://www.lfd.uci.edu/~gohlke/pythonlibs/. Please uninstall another GDAL version if available. Then use pip to install GDAL, rasterio and fiona respectively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.