'How to import (install) arcpy and geopandas and successfully use them in one script?

In my script, I want to use both arcpy and geopandas. So I tried to clone the environment from ArcGIS Pro (2.8.0) first and then install geopandas via anaconda. Even though the geopandas has been successfully installed, when calling the library, errors occured. Any suggestions about setting up these two libraries are really appreciated.



Solution 1:[1]

In case you tried it through ArcGIS Pro's user interface, you are better off to do this in the Python Command Prompt.

  1. Open your Python Command Prompt
  2. Then following commands (assuming the new environment's name is arcgispro-py3-gpd):
activate arcgispro-py3
conda create --name arcgispro-py3-gpd --clone arcgispro-py3
activate arcgispro-py3-gpd
conda install geopandas

You may get some warnings about inconsistent environment. See this ArcGIS Pro Idea starting the thread with this comment.


You can also install arcpy in your own "non-ArcGIS Pro" Conda environment. (ArcGIS Pro still needs to be installed on the same computer.)

In this answer (of the question Can't install arcpy in Jupyter Notebook) I am showing how to install geopandas and jupyterlab in a "non-ArcGIS Pro" Conda environment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thomas