как установить geopandas windows 10
Fastest way to install Geopandas in jupyter notebook on Windows
Hello everyone. Recently I was working on a data science group project in which my part was to make Geospatial visualizations which requires python library Geopandas to be installed in my system. I had two options either do it in jupyter notebook or Google Colab.
I chose jupyter notebook but faced a lot of problems while installing Geopandas.There were not a single good resource on internet which can help me to install Geopandas properly without any errors. So, I decided to write an article which will help all the data science enthusiasts in installing Geopandas easily.
In this article I am going to show the fastest and best way to install Geopandas in jupyter notebook on Windows.So, let’s get started.
First of all, if you will import geopandas without installing it, it will show this error which means we need to install it first.
Installing Geopandas
Follow the steps given below to install geopandas.
Note- Anaconda is assumed to be installed on your system.
Step 1- Open Anaconda command prompt and create new environment variable say “geo_env” in our case using the command given below.
Step 2- Activate this environment “geo_env” and add and set conda-forge channel.
Step 3- Install Geopandas in the environment just created.
Verify that it is installed by running python in your terminal and then running following code.No errors means geopandas is succesfully installed.
Step 4- Next task is to install jupyter notebook in this environment,as by default it is installed only in “base” environment.
Step 5- Now add our environment to jupyter notenook.
Running Geopandas in Jupyter Notebook.
First way- Using Anaconda Navigator.
Open Anaconda Navigator,go to Environments section then select the environment,in our case geo_env. Then click on “play” button and select “Open with Jupyter Notebook”.
Second Way- Using Anaconda Command Prompt.
Follow the following steps.
Step-1 Open Anaconda command prompt.By default it is in “base” environment.
Step 2- Change it to the environment we created “geo_env” and installed geopandas by activating the environment.
Step-3 Run “jupyter notebook” command and get going by either creating a new file or editing an existing ipynb file. Make sure you are working in the environment we have created.
Installation¶
GeoPandas depends for its spatial functionality on a large geospatial, open source stack of libraries (GEOS, GDAL, PROJ). See the Dependencies section below for more details. Those base C libraries can sometimes be a challenge to install. Therefore, we advise you to closely follow the recommendations below to avoid installation problems.
Installing with Anaconda / conda¶
To install GeoPandas and all its dependencies, we recommend to use the conda package manager. This can be obtained by installing the Anaconda Distribution (a free Python distribution for data science), or through miniconda (minimal distribution only containing Python and the conda package manager). See also the installation docs for more information on how to install Anaconda or miniconda locally.
The advantage of using the conda package manager is that it provides pre-built binaries for all the required and optional dependencies of GeoPandas for all platforms (Windows, Mac, Linux).
To install the latest version of GeoPandas, you can then do:
Using the conda-forge channel¶
conda-forge is a community effort that provides conda packages for a wide range of software. It provides the conda-forge package channel for conda from which packages can be installed, in addition to the “defaults” channel provided by Anaconda. Depending on what other packages you are working with, the defaults channel or conda-forge channel may be better for your needs (e.g. some packages are available on conda-forge and not on defaults).
GeoPandas and all its dependencies are available on the conda-forge channel, and can be installed as:
We strongly recommend to either install everything from the defaults channel, or everything from the conda-forge channel. Ending up with a mixture of packages from both channels for the dependencies of GeoPandas can lead to import problems. See the conda-forge section on using multiple channels for more details.
Creating a new environment¶
Creating a new environment is not strictly necessary, but given that installing other geospatial packages from different channels may cause dependency conflicts (as mentioned in the note above), it can be good practice to install the geospatial stack in a clean environment starting fresh.
Installing with pip¶
GeoPandas can also be installed with pip, if all dependencies can be installed as well:
When using pip to install GeoPandas, you need to make sure that all dependencies are installed correctly.
fiona provides binary wheels with the dependencies included for Mac and Linux, but not for Windows.
pyproj, rtree, and shapely provide binary wheels with dependencies included for Mac, Linux, and Windows.
Depending on your platform, you might need to compile and install their C dependencies manually. We refer to the individual packages for more details on installing those. Using conda (see above) avoids the need to compile the dependencies yourself.
Installing from source¶
You may install the latest development version by cloning the GitHub repository and using pip to install from the local directory:
It is also possible to install the latest development version directly from the GitHub repository with:
For installing GeoPandas from source, the same note on the need to have all dependencies correctly installed applies. But, those dependencies can also be installed independently with conda before installing GeoPandas from source:
See the section on conda above for more details on getting running with Anaconda.
How to Install Geopandas on Windows 10 Using pip
In the interest of having a working solution accepted on Stack overflow with as much info as possible on the issues that come up with using pip to install Geopandas or a package like OSMnx that depends on it using pip on Windows 10 I’ll post my workflow below
1 Answer 1
Three possible problems and they have to do with the difference between pip and conda discussed here
First, pip requires Visual C++ to compile packages, while conda does not.
The easiest way to ensure that you have Visual C++ available is to install the community distribution of Visual Studio. Depending on the options selected this is potentially several gbs so a good internet connection helps a lot.
If you have GDAL already installed via OSGeoW64 you’ll need to uninstall that by deleteing the entire OSGEo4w folder in the C: drive
Pick the version for the architecture of python that you have installed, NOT the architecture of your computer. Check using this clever line that offers an indication of what the difference between architectures actually is.
Be sure to pip uninstall
before installing from a wheel or otherwise, and be sure to actually import the packages before assuming that they have installed correctly, even if there weren’t any error messages upon pip install
Lastly, there is a lot of helpful info already out there but not collected in a sinlge place so if there’s something missing of course edit the answer to include.
edit: just tried this with a python environement using the 64bit version of python 3.7.4 and it also worked.
One note, initially, the install failed, OSError: could not find or load spatialindex_c.dll
To solve this and possibly other errors, pip uninstall and pip install the wheels for numpy GDAL Rtree Shapely and Fiona a second time. Either I did not install them in the correct order initially or their is a circular dependency that installing everything twice resolves.
edit: Stackoverflow just told me this q/a has over 1000 views while receiving 0 votes. I’m not concerned about the points or whatever but in the interest of having a working answer, if this doesn’t work for you consider leaving a comment or adding an answer of your own.
Installation¶
GeoPandas depends for its spatial functionality on a large geospatial, open source stack of libraries (GEOS, GDAL, PROJ). See the Dependencies section below for more details. Those base C libraries can sometimes be a challenge to install. Therefore, we advise you to closely follow the recommendations below to avoid installation problems.
Installing with Anaconda / conda¶
To install GeoPandas and all its dependencies, we recommend to use the conda package manager. This can be obtained by installing the Anaconda Distribution (a free Python distribution for data science), or through miniconda (minimal distribution only containing Python and the conda package manager). See also the installation docs for more information on how to install Anaconda or miniconda locally.
The advantage of using the conda package manager is that it provides pre-built binaries for all the required and optional dependencies of GeoPandas for all platforms (Windows, Mac, Linux).
To install the latest version of GeoPandas, you can then do:
Using the conda-forge channel¶
conda-forge is a community effort that provides conda packages for a wide range of software. It provides the conda-forge package channel for conda from which packages can be installed, in addition to the “defaults” channel provided by Anaconda. Depending on what other packages you are working with, the defaults channel or conda-forge channel may be better for your needs (e.g. some packages are available on conda-forge and not on defaults).
GeoPandas and all its dependencies are available on the conda-forge channel, and can be installed as:
We strongly recommend to either install everything from the defaults channel, or everything from the conda-forge channel. Ending up with a mixture of packages from both channels for the dependencies of GeoPandas can lead to import problems. See the conda-forge section on using multiple channels for more details.
Creating a new environment¶
Creating a new environment is not strictly necessary, but given that installing other geospatial packages from different channels may cause dependency conflicts (as mentioned in the note above), it can be good practice to install the geospatial stack in a clean environment starting fresh.
Installing with pip¶
GeoPandas can also be installed with pip, if all dependencies can be installed as well:
When using pip to install GeoPandas, you need to make sure that all dependencies are installed correctly.
fiona provides binary wheels with the dependencies included for Mac and Linux, but not for Windows.
pyproj, rtree, and shapely provide binary wheels with dependencies included for Mac, Linux, and Windows.
Depending on your platform, you might need to compile and install their C dependencies manually. We refer to the individual packages for more details on installing those. Using conda (see above) avoids the need to compile the dependencies yourself.
Installing from source¶
You may install the latest development version by cloning the GitHub repository and using pip to install from the local directory:
It is also possible to install the latest development version directly from the GitHub repository with:
For installing GeoPandas from source, the same note on the need to have all dependencies correctly installed applies. But, those dependencies can also be installed independently with conda before installing GeoPandas from source:
See the section on conda above for more details on getting running with Anaconda.
How to Install Geopandas on Windows?
Geopandas is a Python library used to add geographical data to pandas as an object. In this article, we will look into the process of installing Geopandas on a windows machine.
Pre-requisites:
Installing Geopandas on Windows using Conda:
If you want the installation to be done through conda, open up the Anaconda Powershell Prompt and use the below command:
Type y for yes when prompted.
You will get a similar message once the installation is complete:
Note: If your preferred method of installation is conda-forge, use the below command:
Verifying Geopandas Installation on Windows using Conda:
To verify if Geopandas has been successfully installed in your system run the below command in Anaconda Powershell Prompt:
You’ll get the below message if the installation is complete:
Installing Geopandas on Windows using PIP:
If you want the installation to be done through PIP, open up the Command Prompt and use the below command:
You will get a similar message once the installation is complete:
Verifying Geopandas Installation on Windows using PIP:
To verify if the Geopandas has been successfully installed in your system run the below command in Command Prompt:
You’ll get the below message if the installation is complete: