skip to Main Content

I wish to install geopandas with conda, as it is recommended by the manual.

https://geopandas.org/en/stable/getting_started/install.html

I am working on Linux Ubuntu 22.04 LTS with Python 3.7.4.
I have tried to install geopandas with the following commands:

conda install geopandas
conda install --channel conda-forge geopandas
conda install python=3 geopandas

But it always end up with this error message:

Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. 
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. 
Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. 
Solving environment: / failed

Another attempt has been made creating an environment:

conda create -n geo_env
conda activate geo_env
conda config  --env --add channels conda-forge
conda config --env --set channel_priority strict
conda install geopandas

And it seems to work. Unfortunately, when trying to import the package in Python, the following error show:

>>> import geopandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/usr/anaconda3/lib/python3.7/site-packages/geopandas/__init__.py", line 1, in <module>
    from geopandas._config import options  # noqa
  File "/home/usr/anaconda3/lib/python3.7/site-packages/geopandas/_config.py", line 109, in <module>
    default_value=_default_use_pygeos(),
  File "/home/usr/anaconda3/lib/python3.7/site-packages/geopandas/_config.py", line 95, in _default_use_pygeos
    import geopandas._compat as compat
  File "/home/usr/anaconda3/lib/python3.7/site-packages/geopandas/_compat.py", line 8, in <module>
    import pandas as pd
  File "/home/usr/anaconda3/lib/python3.7/site-packages/pandas/__init__.py", line 142, in <module>
    from pandas.io.api import (
  File "/home/usr/anaconda3/lib/python3.7/site-packages/pandas/io/api.py", line 8, in <module>
    from pandas.io.excel import ExcelFile, ExcelWriter, read_excel
  File "/home/usr/anaconda3/lib/python3.7/site-packages/pandas/io/excel/__init__.py", line 1, in <module>
    from pandas.io.excel._base import ExcelFile, ExcelWriter, read_excel
  File "/home/usr/anaconda3/lib/python3.7/site-packages/pandas/io/excel/_base.py", line 32, in <module>
    from pandas.io.parsers import TextParser
  File "/home/usr/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/__init__.py", line 1, in <module>
    from pandas.io.parsers.readers import (
  File "/home/usr/anaconda3/lib/python3.7/site-packages/pandas/io/parsers/readers.py", line 17, in <module>
    from pandas._typing import (
ImportError: cannot import name 'DtypeArg' from 'pandas._typing' (/home/usr/anaconda3/lib/python3.7/site-packages/pandas/_typing.py)

Would anyone have an idea what is the problem installing geopandas on my device?

2

Answers


  1. This error your getting is due to dependencies conflict

    Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.

    Try creating a new env and install geopandas first, then your other packages.

    Login or Signup to reply.
  2. You’re using anaconda, which comes with a ton of packages installed into your base env from the defaults channel, which is incompatible with conda-forge. essentially have two options:

    1. never use conda-forge. Booooo.

    2. (my recommendation) delete anaconda. I’d recommend installing miniforge (the conda-forge-first version of miniconda) and then installing packages only into environments. The only things that should ever be installed in your base env are cross-environment utilities, such as jupyter or IDEs which can select from multiple environments, or something like mamba which works directly with conda environments.

      If you do this, make sure you do go ahead and uninstall anaconda – having multiple installations of conda floating around in your path is a recipe for disaster.

    The anaconda distribution is an all-in-one package for people who want to get set up with a data science environment out of the box. Unfortunately, polluting your base env leads to big problems down the road if you want to use packages from channels other than defaults. If you like using the anaconda package pack, you can always install it into an environment with miniconda, e.g. conda create -n anaconda -c defaults anaconda

    And if you do decide to start from scratch, if you want to rip off the guardrails and do this much, much more quickly but with harder crashes and worse error messages – use mamba! It’s a clone of conda written to be lightning fast and run in parallel. Since it’s a clone of conda, if you ever get an error message in mamba, just rerun the command in conda. It might just suddenly work, or it might error but give you a much more helpful error message.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search