无法在 Python3 上安装 geopandas

无法在 Python3 上安装 geopandas

我在尝试安装时收到geopandasUbuntu 20.04错误Python3.7

这就是我正在做的事情:

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

以下流程

Processing /home/d1-user/geopandas
Requirement already satisfied: pandas>=0.24.0 in /usr/local/lib/python3.7/site-packages (from geopandas==0.9.0+25.gdd2ed8e) (1.1.5)
Requirement already satisfied: shapely>=1.6 in /usr/local/lib/python3.7/site-packages (from geopandas==0.9.0+25.gdd2ed8e) (1.7.1)
Requirement already satisfied: fiona>=1.8 in /usr/local/lib/python3.7/site-packages (from geopandas==0.9.0+25.gdd2ed8e) (1.8.19)
Collecting pyproj>=2.2.0 (from geopandas==0.9.0+25.gdd2ed8e)
  Using cached https://files.pythonhosted.org/packages/7c/1d/20ea3b603db61ccc60f45064a9e00ba2e6263f1de560e33306f6f3d42fcb/pyproj-3.1.0.tar.gz
  Installing build dependencies ... done
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/site-packages (from pandas>=0.24.0->geopandas==0.9.0+25.gdd2ed8e) (2021.1)
Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.7/site-packages (from pandas>=0.24.0->geopandas==0.9.0+25.gdd2ed8e) (1.20.3)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/site-packages (from pandas>=0.24.0->geopandas==0.9.0+25.gdd2ed8e) (2.8.1)
Requirement already satisfied: certifi in /usr/local/lib/python3.7/site-packages (from fiona>=1.8->geopandas==0.9.0+25.gdd2ed8e) (2020.12.5)
Requirement already satisfied: six>=1.7 in /usr/local/lib/python3.7/site-packages (from fiona>=1.8->geopandas==0.9.0+25.gdd2ed8e) (1.16.0)
Requirement already satisfied: click-plugins>=1.0 in /usr/local/lib/python3.7/site-packages (from fiona>=1.8->geopandas==0.9.0+25.gdd2ed8e) (1.1.1)
Requirement already satisfied: cligj>=0.5 in /usr/local/lib/python3.7/site-packages (from fiona>=1.8->geopandas==0.9.0+25.gdd2ed8e) (0.7.1)
Requirement already satisfied: click<8,>=4.0 in /usr/local/lib/python3.7/site-packages (from fiona>=1.8->geopandas==0.9.0+25.gdd2ed8e) (7.1.2)
Requirement already satisfied: munch in /usr/local/lib/python3.7/site-packages (from fiona>=1.8->geopandas==0.9.0+25.gdd2ed8e) (2.5.0)
Requirement already satisfied: attrs>=17 in /usr/local/lib/python3.7/site-packages (from fiona>=1.8->geopandas==0.9.0+25.gdd2ed8e) (21.2.0)
Installing collected packages: pyproj, geopandas
  Running setup.py install for pyproj ... error
    Complete output from command /usr/local/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4tpthiyu/pyproj/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-56avnl0l/install-record.txt --single-version-externally-managed --compile:
    /tmp/pip-build-env-xjhuovi8/lib/python3.7/site-packages/setuptools/dist.py:694: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
      % (opt, underscore_opt))
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/_show_versions.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/utils.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/proj.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/compat.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/enums.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/network.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/datadir.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/exceptions.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/sync.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/aoi.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/geod.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/__init__.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/transformer.py -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/__main__.py -> build/lib.linux-x86_64-3.7/pyproj
    creating build/lib.linux-x86_64-3.7/pyproj/crs
    copying pyproj/crs/_cf1x8.py -> build/lib.linux-x86_64-3.7/pyproj/crs
    copying pyproj/crs/enums.py -> build/lib.linux-x86_64-3.7/pyproj/crs
    copying pyproj/crs/datum.py -> build/lib.linux-x86_64-3.7/pyproj/crs
    copying pyproj/crs/__init__.py -> build/lib.linux-x86_64-3.7/pyproj/crs
    copying pyproj/crs/coordinate_system.py -> build/lib.linux-x86_64-3.7/pyproj/crs
    copying pyproj/crs/coordinate_operation.py -> build/lib.linux-x86_64-3.7/pyproj/crs
    copying pyproj/crs/crs.py -> build/lib.linux-x86_64-3.7/pyproj/crs
    copying pyproj/_sync.pyi -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/_transformer.pyi -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/_geod.pyi -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/list.pyi -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/database.pyi -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/_crs.pyi -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/_datadir.pyi -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/_network.pyi -> build/lib.linux-x86_64-3.7/pyproj
    copying pyproj/py.typed -> build/lib.linux-x86_64-3.7/pyproj
    running build_ext
    building 'pyproj._geod' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/pyproj
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include -I/usr/local/include/python3.7m -c pyproj/_geod.c -o build/temp.linux-x86_64-3.7/pyproj/_geod.o
    pyproj/_geod.c:639:10: fatal error: geodesic.h: No such file or directory
      639 | #include "geodesic.h"
          |          ^~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/local/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4tpthiyu/pyproj/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-56avnl0l/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-4tpthiyu/pyproj/

答案1

根据Geopandas 文档(重点是我自己):

根据您的平台,您可能需要编译和安装 它们的 C 依赖项。有关安装这些软件包的更多详细信息,请参阅各个软件包。使用 conda(参见上文)可避免自行编译依赖项。

因此请确保在运行之前已python-dev安装:build-essentialpip install .

sudo apt install python3-dev build-essential
  • python3-dev包含 Python 的头文件和静态库,默认情况下应该已经安装。这个类似的问题并且似乎解决了 OP 的问题。

  • build-essential是一个元包,它安装编译包所需的最常用工具(gcc、、等等)。g++make

相关内容