r-barnes / richdem

High-performance Terrain and Hydrology Analysis
GNU General Public License v3.0
271 stars 69 forks source link

Installation Failure #66

Open idhidro opened 1 year ago

idhidro commented 1 year ago

I have been attempting to install PyLEnM and the installation has failed while installing richdem. I am using Python 3.10.1, pip 23.0, setup tools 65.5,and Visual Studio 2022. I have down graded to VS 2019 and have used the --use pep 517 option and the installation still fails. The installation errors are:

DEPRECATION: richdem is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559

"command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\cl.exe' failed with exit code 2".

Any suggestions would be appreciated. Thanks.

faluhong commented 1 year ago

I got the same exit code 2 issue when installing richdem using Python 3.10.9, Visual Studis 2022, Windows 11. I got the error of C2065 and C2338

I tries using the solution provided in https://github.com/davisking/dlib/issues/2463#issuecomment-976756345. But it is not working for richdem. Maybe the pybind11 need updated? (https://github.com/r-barnes/richdem/issues/46#issue-1051016963)

richdem.cpp "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DDOCTEST_CONFIG_DISABLE -DRICHDEM_COMPILE_TIME=\"\\"Unknown\\"\" -DRICHDEM_GIT_HASH=\"\\"Unknown\\"\" -DRICHDEM_LOGGING -D_USE_MATH_DEFINES -Ilib/ -IC:\Users\64937\anaconda3\include -IC:\Users\64937\anaconda3\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /EHsc /Tpsrc\pywrapper.cpp /Fobuild\temp.win-amd64-cpython-310\Release\src\pywrapper.obj -std=c++11 -g -fvisibility=hidden -O3 cl : Command line warning D9002 : ignoring unknown option '-std=c++11' cl : Command line warning D9002 : ignoring unknown option '-g' cl : Command line warning D9002 : ignoring unknown option '-fvisibility=hidden' cl : Command line warning D9002 : ignoring unknown option '-O3' pywrapper.cpp lib/pybind11/numpy.h(35): error C2065: 'ssize_t': undeclared identifier lib/pybind11/numpy.h(35): error C2338: static_assert failed: 'ssize_t != Py_intptr_t' src\pywrapper.cpp(226): warning C4244: 'argument': conversion from 'const pybind11::ssize_t' to 'const richdem::Array3D::xy_t', possible loss of data src\pywrapper.cpp(226): warning C4244: 'argument': conversion from 'const pybind11::ssize_t' to 'const richdem::Array3D::xy_t', possible loss of data error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\cl.exe' failed with exit code 2

bwj202 commented 1 year ago

Not sure if you are still having this issue but I wondered if you tried installing using conda? That has its own issues that I struggled with for quite some time but I finally got it working using the workflow below. It's a bit of a messy solution and there might be a better way of doing it but it worked:

Install Visual studio build tools 2019

  • ensure that you install Desktop development with C++ (essential)
  • once installed browse to "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" (or wherever you installed build tools) and copy the "VC" folder
  • Paste the VC folder into "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" open up anaconda prompt
  • You might want to create and activate a new environment, I did, so if it doesn't work without the new environment try that first.
  • conda install -c conda-forge python gdal richdem

Hopefully this works for you.