Search code examples
pythonpandasgeopandas

Describing GeoPandas dependency in requirements.txt


I am developing a Python package based on my GeoPandas data processing logic. I am using Elementary OS 5 and Python 3.8.

I created an empty requirements.txt file on my project root, and added geopandas in it.

# requirements.txt
geopandas

Next, I created a new virtual environment with python3.8 -m venv myenv and activated it. But when I tried to install geopandas using pip command, I got the following error

(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) $

I searched for a while but most of answers I tried didn't help because I was stuck on setting up pyproj.

How can I solve this issue correctly?


Solution

  • If you do not need the recent version of GeoPandas, you can use GeoPandas < 0.7.

    Here's a sample requirements.txt file.

    pyproj==1.9.6
    geopandas==0.6.3
    

    I tried several versions of pyproj, but 1.9.6 was the easiest version to install on Ubuntu 18.04 and 20.04. Note that pyproj==1.9.6 dependency must be before the geopandas line.