Fan Wu
Fan Wu

Reputation: 169

ImportError: No module named geopandas

I just ran this code and got this error, I'm not sure why:

%matplotlib inline
​
import seaborn as sns
import pandas as pd
import pysal as ps
import geopandas as gpd
import numpy as np
import matplotlib.pyplot as pet

ImportError: No module named geopandas

Upvotes: 11

Views: 90568

Answers (5)

SpatialNasir
SpatialNasir

Reputation: 195

As mentioned by @marianoju, the problem is likely because you do not have IPython installed in your current environment.

The simple solution is to install IPython in your current environment.

conda install ipython

An even better solution (in my opinion) is to install Jupyter notebook, Jupyter lab in your new conda environment.

conda install jupyter

conda install jupyterlab

This will install jupyter(lab) along with its all dependencies (and that includes IPython). So, any other lurking dependency issues would have been solved in one command.

Upvotes: -1

marianoju
marianoju

Reputation: 346

You might encounter this problem even if geopandas is correctly installed in your active environment. Your problem might be related to ipython not being installed in the environment you installed geopandas in. In this case ipython from outside of the environment is used and will find no module named geopandas resulting in a ImportError.

Assuming a Linux OS:

  • You can check which ipython is used with where ipython.
  • You can install ìpython in your active environment by executing conda install ipython.

Upvotes: 8

mpriya
mpriya

Reputation: 893

If you have any trouble installing GeoPandas, just follow the below steps:

⦁ Go to Unofficial Windows Binaries for Python Extension Packages. (https://www.lfd.uci.edu/~gohlke/pythonlibs/)

⦁ Download the following binaries in a specifi folder in your laptop/PC:

GDAL,

Pyproj,

Fiona,

Shapely &

Geopandas

matching the version of Python, and whether the 32-bit or 64-bit OS is installed on your laptop. (E.g. for Python v3.8x (64-bit), GDAL package should be GDAL-3.3.2-cp38-cp38-win_amd64.whl)

Go to the folder where the binaries are downloaded in the command prompt window. (C:\Users\abc\GeoPandas dependencies) Order of execution of the following commands matter.

pip install .\GDAL-3.3.2-cp38-cp38-win_amd64.whl

pip install .\pyproj-3.2.0-cp38-cp38-win_amd64.whl

pip install .\Fiona-1.8.20-cp38-cp38-win_amd64.whl

pip install .\Shapely-1.7.1-cp38-cp38-win_amd64.whl

pip install .\geopandas-0.9.0-py3-none-any.whl

Credit

Upvotes: 1

Tanmesh Shah
Tanmesh Shah

Reputation: 77

If using Jupyter notebook with conda use:

conda install -c conda-forge geopandas

Upvotes: 3

sinhayash
sinhayash

Reputation: 2803

Check if geopandas is installed

>>> import sys
>>> 'geopandas' in sys.modules
False                            => Not Installed
>>> 

To install the released version, you can use pip:

pip install geopandas

or you can install the conda package from the conda-forge channel:

conda install -c conda-forge geopandas

You may install the latest development version by cloning the GitHub repository and using the setup script:

git clone https://github.com/geopandas/geopandas.git
cd geopandas
pip install .

It is also possible to install the latest development version directly from the GitHub repository with:

pip install git+git://github.com/geopandas/geopandas.git

Linux?

sudo apt-get install python-geopandas

Upvotes: 18

Related Questions