4

I am relatively new to python and trying to install geopandas on python 3.7 using pip. For separate reasons, I would like to avoid using the anaconda distribution. Following this post, I was able to successfully install geopandas by first installing the dependencies manually. The problem is that now I run into a problem when I try to import geopandas:

import geopandas

The subsequent error message is:

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\geopandas\__init__.py", line 5, in <module>
from geopandas.io.file import read_file

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\geopandas\io\file.py", line 4, in <module>
import fiona

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fiona\__init__.py", line 87, in <module>
from fiona.collection import BytesCollection, Collection

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fiona\collection.py", line 9, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator

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

Any advice would be greatly appreciated

Xukrao
  • 8,003
  • 5
  • 26
  • 52
Robusta
  • 41
  • 1
  • 1
  • 3
  • What have you done since then ? – keepAlive Apr 26 '20 at 13:12
  • 1
    I gave up and used it with the anaconda distribution. For some reason it works well there. You can install miniconda if you don't want the full distribution, and then conda install -c conda-forge geopandas installs all the dependencies by itself – Robusta Apr 28 '20 at 13:45

3 Answers3

22

My case is similar to yours. And here is how I got mine setup:

Platform: Windows 10, 64-bit Python Version: Python 3.7

Dependencies (whl files needed):

  1. GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl
  2. Fiona‑1.8.13‑cp37‑cp37m‑win_amd64.whl
  3. pyproj‑2.6.0‑cp37‑cp37m‑win_amd64.whl
  4. Rtree‑0.9.4‑cp37‑cp37m‑win_amd64.whl

Steps:

  1. Download the files that match the platform and Python version from

    https://www.lfd.uci.edu/~gohlke/pythonlibs/

  2. Install packages (stick with the order)

a) C:\Users...\Python37\Scripts>pip3.7 install C:...\GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl

b) C:\Users...\Python37\Scripts>pip3.7 install C:...\Fiona‑1.8.13‑cp37‑cp37m‑win_amd64.whl

c) C:\Users...\Python37\Scripts>pip3.7 install C:...\pyproj‑2.6.0‑cp37‑cp37m‑win_amd64.whl

d) C:\Users...\Python37\Scripts>pip3.7 install C:...\Rtree‑0.9.4‑cp37‑cp37m‑win_amd64.whl

  1. Given no errros, now it's good to go:

C:\Users...\Python37\Scripts>pip3.7.exe install geopandas

  1. Test it using IDEL 3.7.4

    import geopandas as pdg

(It works!)

This works for me and I hope this is also helpful for you.

Harry
  • 1,147
  • 13
  • 13
  • 2
    I had problem when I was installing GDAL but `.whl` file helped me. https://gis.stackexchange.com/questions/343835/installing-rasterio-and-gdal-api-in-a-virtuallenv-in-windows-10/371720#371720 – ArashMad Dec 22 '20 at 09:55
  • Works perfectly, thanks! I also installed _shapely_ using the same method as the others before installing geopandas because they mention it on their [website](https://geopandas.org/getting_started/install.html#installing-with-pip). Maybe it makes no difference? Also, do you need to use `pip install wheel` beforehand? – Lawrence May 08 '21 at 00:18
  • Your suggested steps also worked nicely with Python 3.8.8 on Windows 10. – jaweej Aug 13 '21 at 12:04
  • Thanks. It also worked with python 3.10 on windows 10 amd64 with a little try. – Mahdi Nazari Ashani Dec 05 '21 at 20:42
0

I had trouble installing geopandas on (win-64, Spyder3.8, Python3.8.3) Use this expression to install geopandas in anaconda prompt: conda install -c conda-forge/label/cf202003 geos (do not use this website: https://geopandas.org/install.html) (do not use this expression: conda install --channel conda-forge geopandas)

0

The simplest method to install geopandas is:

conda install geopandas

In order to update geopandas to latest version use the following command after installation by conda:

pip install geopandas --upgrade 

There are other installation methods also explained in Geopandas official website.

Conda is really powerful when it comes to installation as it will install the dependencies needed by the package. However, if you would like to install dependencies earlier than use the following command:

conda install pandas fiona shapely pyproj rtree descartes

Note that if you have installed the dependencies using above command then you can also use pip to install geopandas but before installing via pip dependencies are required to be installed. In order to read more about dependencies, please follow the official guide. To install using pip use the following command:

pip install geopandas
Dr. Arslan
  • 1,254
  • 1
  • 16
  • 27