在 requirements.txt 中描述 GeoPandas 依赖项

Describing GeoPandas dependency in requirements.txt

我正在开发一个基于我的 GeoPandas 数据处理逻辑的 Python 包。 我正在使用 Elementary OS 5 和 Python 3.8.

我在项目根目录下创建了一个空 requirements.txt 文件,并在其中添加了 geopandas

# requirements.txt
geopandas

接下来,我使用 python3.8 -m venv myenv 创建了一个新的虚拟环境并激活了它。 但是当我尝试使用 pip 命令安装 geopandas 时,出现以下错误

(myenv) $ pip install -r requirements.txt
...
Collecting pyproj>=2.2.0 (from geopandas->-r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/2c/12/7a8cca32506747c05ffd5c6ba556cf8435754af0939906cbcc7fa5802ea3/pyproj-3.0.1.tar.gz
    Complete output from command python setup.py egg_info:
    ERROR: Cython.Build.cythonize not found. Cython is required to build pyproj.
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-u6x_qwoi/pyproj/
(myenv) $

我搜索了一段时间,但我尝试的大部分答案都没有帮助,因为我一直在设置 pyproj

如何正确解决这个问题?

如果不需要最新版本的GeoPandas,可以使用GeoPandas < 0.7。

这是一个示例 requirements.txt 文件。

pyproj==1.9.6
geopandas==0.6.3

我尝试了多个 pyproj 版本,但 1.9.6 是在 Ubuntu 18.04 和 20.04 上安装最简单的版本。 请注意,pyproj==1.9.6 依赖项必须在 geopandas 行之前。

如错误消息所述,Cython is required to build pyproj.。需要安装Cython才能成功pip install pyproj。

pip install Cython

但是请注意,通常不建议使用 pip 安装 geopandas 及其依赖项,如果可能,您应该更喜欢 conda。