creare-com / pydem

Python library for Global Hydrology Analysis. Used to calculate upstream contributing area, aspect, slope, and topographic wetness index.
Apache License 2.0
113 stars 35 forks source link

Installation issue #27

Open woj-kaczan opened 1 month ago

woj-kaczan commented 1 month ago

I am encountering a problem during pydem installation.

I've tried to install it using python 2.7 and python3 on windows and wsl.

Python=3.12.4

error

  Using cached pyDEM-1.0.0.tar.gz (136 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\wojciech.kaczan\AppData\Local\Temp\pip-install-xvce4z5x\pydem_030c095be18b4af795ec6f1d6dcafe74\setup.py", line 27, in <module>
          from Cython.Build import cythonize
      ModuleNotFoundError: No module named 'Cython'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

after installing cython:

Building wheels for collected packages: pydem, asciitree
  Building wheel for pydem (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-312
      creating build\lib.win-amd64-cpython-312\pydem
      copying pydem\commandline_utils.py -> build\lib.win-amd64-cpython-312\pydem
      copying pydem\dem_processing.py -> build\lib.win-amd64-cpython-312\pydem
      copying pydem\process_manager.py -> build\lib.win-amd64-cpython-312\pydem
      copying pydem\utils.py -> build\lib.win-amd64-cpython-312\pydem
      copying pydem\utils_test_pydem.py -> build\lib.win-amd64-cpython-312\pydem
      copying pydem\__init__.py -> build\lib.win-amd64-cpython-312\pydem
      creating build\lib.win-amd64-cpython-312\pydem\cyfuncs
      copying pydem\cyfuncs\__init__.py -> build\lib.win-amd64-cpython-312\pydem\cyfuncs
      running build_ext
      building 'pydem.cyfuncs.cyutils' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pydem
  Running setup.py clean for pydem
  Building wheel for asciitree (setup.py) ... done
  Created wheel for asciitree: filename=asciitree-0.3.3-py3-none-any.whl size=5048 sha256=9eaf147b42d2c64c38d17b3707c7f619237605de5bf7ff239254c0051e527529
  Stored in directory: c:\users\wojciech.kaczan\appdata\local\pip\cache\wheels\a5\d7\98\f56ae733748cd0fa577172bda0e73e0b1f1793c98e09b9e458
Successfully built asciitree
Failed to build pydem
ERROR: Could not build wheels for pydem, which is required to install pyproject.toml-based projects`

The environment:

name: wet-dem
channels:
  - defaults
dependencies:
  - affine=2.3.0=pyhd3eb1b0_0
  - attrs=23.1.0=py312haa95532_0
  - blas=1.0=mkl
  - bzip2=1.0.8=h2bbff1b_6
  - ca-certificates=2024.3.11=haa95532_0
  - certifi=2024.6.2=py312haa95532_0
  - cfitsio=3.470=h2bbff1b_7
  - click=8.1.7=py312haa95532_0
  - click-plugins=1.1.1=pyhd3eb1b0_0
  - cligj=0.7.2=pyhd3eb1b0_0
  - colorama=0.4.6=py312haa95532_0
  - curl=8.7.1=he2ea4bf_0
  - expat=2.6.2=hd77b12b_0
  - freexl=1.0.6=h2bbff1b_0
  - geos=3.8.0=h33f27b4_0
  - geotiff=1.7.0=h4545760_1
  - hdf4=4.2.13=h712560f_2
  - hdf5=1.10.6=h1756f20_1
  - icc_rt=2022.1.0=h6049295_2
  - intel-openmp=2023.1.0=h59b6b97_46320
  - jpeg=9e=h2bbff1b_1
  - kealib=1.4.14=hde4a422_1
  - krb5=1.20.1=h5b6d351_0
  - lerc=3.0=hd77b12b_0
  - libcurl=8.7.1=h86230a5_0
  - libdeflate=1.17=h2bbff1b_1
  - libffi=3.4.4=hd77b12b_1
  - libgdal=3.0.2=hc12e7b7_6
  - libiconv=1.16=h2bbff1b_3
  - libnetcdf=4.8.1=h6685c40_2
  - libpng=1.6.39=h8cc25b3_0
  - libpq=12.17=h906ac69_0
  - libspatialite=4.3.0a=h6ec8781_23
  - libssh2=1.11.0=h291bd65_0
  - libtiff=4.5.1=hd77b12b_0
  - libxml2=2.10.4=h0ad7f3c_2
  - libzip=1.8.0=h289538f_1
  - lz4-c=1.9.4=h2bbff1b_1
  - m2w64-expat=2.1.1=2
  - m2w64-gcc-libgfortran=5.3.0=6
  - m2w64-gcc-libs=5.3.0=7
  - m2w64-gcc-libs-core=5.3.0=7
  - m2w64-gettext=0.19.7=2
  - m2w64-gmp=6.1.0=2
  - m2w64-libiconv=1.14=6
  - m2w64-libwinpthread-git=5.0.0.4634.697f757=2
  - m2w64-xz=5.2.2=2
  - mkl=2023.1.0=h6b88ed4_46358
  - mkl-service=2.4.0=py312h2bbff1b_1
  - mkl_fft=1.3.8=py312h2bbff1b_0
  - mkl_random=1.2.4=py312h59b6b97_0
  - msys2-conda-epoch=20160418=1
  - numpy=1.26.4=py312hfd52020_0
  - numpy-base=1.26.4=py312h4dde369_0
  - openjpeg=2.4.0=h4afccc4_1
  - openssl=3.0.14=h827c3e9_0
  - pip=24.0=py312haa95532_0
  - proj=6.2.1=h3758d61_0
  - pyparsing=3.0.9=py312haa95532_0
  - python=3.12.4=h14ffc60_1
  - rasterio=1.2.10=py312hf4cbf27_0
  - setuptools=69.5.1=py312haa95532_0
  - snuggs=1.4.7=pyhd3eb1b0_0
  - sqlite=3.45.3=h2bbff1b_0
  - tbb=2021.8.0=h59b6b97_0
  - tiledb=2.3.3=hd8964de_3
  - tk=8.6.14=h0416ee5_0
  - tzdata=2024a=h04d1e81_0
  - vc=14.2=h2eaa2aa_4
  - vs2015_runtime=14.29.30133=h43f2093_4
  - wheel=0.43.0=py312haa95532_0
  - xerces-c=3.2.4=hd77b12b_1
  - xz=5.4.6=h8cc25b3_1
  - zlib=1.2.13=h8cc25b3_1
  - zstd=1.5.5=hd43e919_2
  - pip:
      - cython==3.0.10
edencharcon commented 1 month ago

got the same error, any solutions ?

mpu-creare commented 1 month ago

I'll look into it.

Are you both using anaconda environments?

The error basically says that the Cython extensions can't compile because it wants the Microsoft compiler. Generally, on WSL you can use the GCC compiler, but I'll try that out to see if it works.

mpu-creare commented 1 month ago

I tend to use pyenv as my virtual environment manager. I'm still on Python 3.11, but here's a fresh install of Pydem on WSL:

pyenv virtualenv 3.11.2 pydem
pyenv activate pydem
pip install numpy cython
pip install pydem

And that works just fine... but I do have gcc/g++ installed in my WSL (I'm using Ubuntu):

sudo apt update
sudo apt install build-essential
gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

We're also working on a Docker version of Pydem.

Does any of the above help?

mpu-creare commented 1 month ago

Newest version is now 1.1.0 -- and I think I did a better job with the wheel, so perhaps that will help.