r-barnes / richdem

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

installing on wndows #8

Open npongo opened 6 years ago

npongo commented 6 years ago

I am trying to install in windows and having no luck. Below is the error I get: C:\Users\npongo\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DDOCTEST_CONFIG_DISABLE "-DRICHDEM_COMPILE_TIME="2018-01-06 11:21:19 -0600"" -DRICHDEM_GIT_HASH="ef44525" -DRICHDEM_LOGGING -Ilib/ -Ic:\python27\include -Ic:\python27\PC /Tpsrc\pywrapper.cpp /Fobuild\temp.win-amd64-2.7\Release\src\pywrapper.obj -std=c++11 -g -fvisibility=hidden -O3 -Wno-unknown-pragmas cl : Command line error D8021 : invalid numeric argument '/Wno-unknown-pragmas' error: command 'C:\Users\npongo\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe' failed with exit status 2

I have played with the setup.py to remove this argument but still no luck, It then does not find the random.cpp file

any help or suggests welcome on how to build this on windows.

r-barnes commented 6 years ago

I have not tested Windows development significantly. Would the Python wrapper suit your needs? This is likely the easiest way to get going.

Can you remove the Wno-unknown-pragmas and post the error message you see about random.cpp?

konradhafen commented 6 years ago

I get a similar error when installing the python wrapper on windows with pip3.

cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DDOCTEST_CONFIG_DISABLE "-DRICHDEM_COMPILE_TIME="2018-05-20 11:01:43 -0600"" -DRICHDEM_GIT_HASH="a12da15" -DRICHDEM_LOGGING -Ilib/ -IC:\Users\khafe\Anaconda3\include -IC:\Users\khafe\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" /EHsc /Tpsrc\pywrapper.cpp /Fobuild\temp.win-amd64-3.6\Release\src\pywrapper.obj -std=c++11 -g -fvisibility=hidden -O3 -Wno-unknown-pragmas error: command 'cl.exe' failed: No such file or directory

r-barnes commented 6 years ago

@konradhafen: cl.exe is something specified by your Python build system and, therefore, not something I can fix.

A quick Google search reveals the following helpful information: https://stackoverflow.com/questions/41724445/python-pip-on-windows-command-cl-exe-failed

r-barnes commented 6 years ago

@npongo: I've added compiler detection to the Python setup system. Is it possible for you to test from dev?

HCA97 commented 6 years ago

Hi, I tried to install on windows 10 python 3.5 via pip3 unfortunately it failed. The console output was to long so, I put it in a text file.

It gave me this error;

Command "c:\users\cem\appdata\local\programs\python\python35\python.exe -u -c "import 
setuptools, tokenize;__file__='C:\\Users\\Cem\\AppData\\Local\\Temp\\pip-install-
bet0wmkq\\richdem\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', 
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Cem\AppData\Local\Temp\pip-
record-oc6kjfb3\install-record.txt --single-version-externally-managed --compile" failed with error code 
1 in C:\Users\Cem\AppData\Local\Temp\pip-install-bet0wmkq\richdem\

I also got a lot of warnings related to conversion of types and cl.exe.

console output.txt

r-barnes commented 6 years ago

@HCA97 : Do you know which version of MSVC are you using?

HCA97 commented 6 years ago

Hi, I think I am using MSC v.1900 64 bit. image

r-barnes commented 6 years ago

@HCA97: I think I have a workaround. Would you be up for trying to build from dev?

Alternatively, I'm working on getting Appveyor setup after which it might be possible to install without having to compile locally. Or, at least, for me to test things on my end. But it could take a couple of weeks before I get that fully running.

HCA97 commented 6 years ago

Hi,

I tried to build it but it gave me again warnings related to cl.exe and this time I got these errors:

src\pywrapper.cpp(2): fatal error C1083: Cannot open include file: 
'richdem/depressions/depressions.hpp': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' 
failed with exit status 2

This is the console output:

C:\richdem\wrappers\pyrichdem>python setup.py build
Warning! Could not find RichDEM version. Software will still work, but reproducibility will be compromised.
Using RichDEM hash=Unknown, time=Unknown
running build
running build_py
running build_ext
COMPILER msvc
COMPILER ARGUMENTS ['-std=c++11', '-g', '-fvisibility=hidden', '-O3']
building '_richdem' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DDOCTEST_CONFIG_DISABLE -DRICHDEM_COMPILE_TIME="\"Unknown\"" -DRICHDEM_GIT_HASH="\"Unknown\"" -DRICHDEM_LOGGING -Ilib/ -IC:\Users\Cem\AppData\Local\Programs\Python\Python35\include -IC:\Users\Cem\AppData\Local\Programs\Python\Python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpsrc\pywrapper.cpp /Fobuild\temp.win-amd64-3.5\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
src\pywrapper.cpp(2): fatal error C1083: Cannot open include file: 'richdem/depressions/depressions.hpp': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
xuezhicang commented 6 years ago

I guess I have the same problem with above. @HCA97 have you figured out how do we fix it?

error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\cl.exe' failed with exit status 2

----------------------------------------

Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;file='C:\Users\cc\AppData\Local\Temp\pip-build-ldntqcev\richdem\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\cc\AppData\Local\Temp\pip-bx59xunw-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\cc\AppData\Local\Temp\pip-build-ldntqcev\richdem\

r-barnes commented 6 years ago

Looks as though it's some kind of include issue. I'll try to get ahold of a Windows machine this weekend to look into it.

Firiyuu commented 6 years ago

I'm still getting this same kind of error. Did this have any solution for a fix?

xuezhicang commented 6 years ago

@Firiyuu hi i tried the virtual machine which can use Linux. The install process is very easy and straightforward. Try that, that should be a easy way than installing it in Windows.

r-barnes commented 6 years ago

@Firiyuu and @xuezhicang and @HCA97 and @konradhafen and @npongo : I've got access to a Windows via virtual box. If you have any instructions for duplicating your build environments, I'd be interested in hearing them. I'm not sure how to get pip running with a C++ compiler on Windows. Once I have this set up, it should be significantly easier to get this working for you all.

konradhafen commented 6 years ago

@r-barnes @Firiyuu @xuezhicang @HCA97 @npongo : I was able to successfully install richdem on Python 3.6 on Windows 10. The problem I was running into was the link between pip and they Microsoft C++ compiler. From the command line I updated pip python3 -m pip --upgrade pip and installed setuptools python3 -m pip install setuptools. I downloaded and installed the Microsoft Visual C++ 14.0. Making sure my setuptools version matched the listed requirement. After I made these changes, python3 -m pip install richdem worked successfully. I haven't tested the richdem functionality yet.

r-barnes commented 6 years ago

Congrats, @konradhafen! Have you tested any functionality? Is there anything I can do to streamline or otherwise document the process you describe? (I'm working on getting Python Wheels built for Windows, but the process is somewhat mysterious.)

konradhafen commented 6 years ago

@r-barnes : Once I figured out what was causing the problem, the installation fairly simple. Building the Python Wheels would probably be the best way to streamline installation. I have done some testing. For the most part I'm very impressed, especially with the speed of the flow accumulation routines. I have encountered one problem, a bad alloc error on a large dataset. I've tested with DEMs of size 9000 x 6000, 10,000 x 9000, and 18,000 x 26,000. The flow accumulation routine on the largest DEM is when the bad alloc error is thrown. Otherwise, everything works great.

r-barnes commented 6 years ago

@konradhafen : I'll certainly keep wheels on the todo list, then. It's just quite a bother getting an automated compilation and distribution process going.

Yes, I suspected that larger DEMs would have a problem. I have a paper and associated code describing how to do D8 flow accumulation for trillion-cell DEMs and an algorithm in my head that would enable the same for MFD methods.

For small DEMs, such as the 9k x 6k you mention, I increase the algorithm's speed by using a significant amount of auxillary memory to cache intermediate results.

The medium-sized DEMs are more problematic since they're not really large enough to justify the first solution and too large for the second. If you would like to do processing on that 18k x 26k set, I could build out an algorithm to handle it, but it'll run a little slower since I'll have to disable the caching. Let me know if that's of interest.

konradhafen commented 6 years ago

@r-barnes I'll work with rich-dem a little more and and let you know my thoughts on the the algorithm for large rasters. Right now I'm investigating rich-dem for a project that isn't totally off the ground yet so I'm not exactly sure what I need.

tylaa commented 3 years ago

Hello,

i have the same problem to install richdem on windows with python 3.7. Pip and setuptools are up to date. pip 21.0.1 setuptools 53.1.0

`ERROR: Command errored out with exit status 1: command: 'c:\users\maple\pycharmprojects\demvalidation\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Maple\AppData\Local\Temp\pip-install-vdudjuoe\richdem_f6eb4440723749feafec 13f82a80bdd3\setup.py'"'"'; file='"'"'C:\Users\Maple\AppData\Local\Temp\pip-install-vdudjuoe\richdem_f6eb4440723749feafec13f82a80bdd3\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace( '"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\Maple\AppData\Local\Temp\pip-record-qbnukgla\install-record.txt' --single-version-externally-managed --compile --install- headers 'c:\users\maple\pycharmprojects\demvalidation\venv\include\site\python3.7\richdem' cwd: C:\Users\Maple\AppData\Local\Temp\pip-install-vdudjuoe\richdem_f6eb4440723749feafec13f82a80bdd3\ Complete output (28 lines): Warning! Could not find RichDEM version. Software will still work, but reproducibility will be compromised. Using RichDEM hash=Unknown, time=Unknown running install running build running build_py creating build creating build\lib.win-amd64-3.7 creating build\lib.win-amd64-3.7\richdem copying richdem\cli.py -> build\lib.win-amd64-3.7\richdem copying richdem__init__.py -> build\lib.win-amd64-3.7\richdem running build_ext COMPILER msvc COMPILER ARGUMENTS ['-std=c++11', '-g', '-fvisibility=hidden', '-O3'] building '_richdem' extension creating build\temp.win-amd64-3.7 creating build\temp.win-amd64-3.7\Release creating build\temp.win-amd64-3.7\Release\src creating build\temp.win-amd64-3.7\Release\lib creating build\temp.win-amd64-3.7\Release\lib\richdem creating build\temp.win-amd64-3.7\Release\lib\richdem\common C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DDOCTEST_CONFIG_DISABLE -DRICHDEM_COMPILE_TIME="\"Unknown\"" -DRICHDEM_GIT_HASH="\ "Unknown\"" -DRICHDEM_LOGGING -D_USE_MATH_DEFINES -Ilib/ -Ic:\users\maple\pycharmprojects\demvalidation\venv\include -IC:\Users\Maple\AppData\Local\Programs\Python\Python37\include -IC:\Users\Maple\AppData\Local\Programs\Python\Python3 7\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\include" /EHsc /Tpsrc\pywrapper.cpp /Fobuild\temp.win-amd64-3.7\Release\src\pywrapper.obj -std=c++11 -g -fvisibility=hidden -O3 cl : Befehlszeile warning D9002 : Unbekannte Option "-std=c++11" wird ignoriert. cl : Befehlszeile warning D9002 : Unbekannte Option "-g" wird ignoriert. cl : Befehlszeile warning D9002 : Unbekannte Option "-fvisibility=hidden" wird ignoriert. cl : Befehlszeile warning D9002 : Unbekannte Option "-O3" wird ignoriert. pywrapper.cpp C:\Users\Maple\AppData\Local\Programs\Python\Python37\include\pyconfig.h(59): fatal error C1083: Datei (Include) kann nicht ge”ffnet werden: "io.h": No such file or directory error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe' failed with exit status 2

ERROR: Command errored out with exit status 1: 'c:\users\maple\pycharmprojects\demvalidation\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Maple\AppData\Local\Temp\pip-install-vdudj uoe\richdem_f6eb4440723749feafec13f82a80bdd3\setup.py'"'"'; file='"'"'C:\Users\Maple\AppData\Local\Temp\pip-install-vdudjuoe\richdem_f6eb4440723749feafec13f82a80bdd3\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open) (file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\Maple\AppData\Local\Temp\pip-record-qbnukgla\install-record.txt' --single-version-extern ally-managed --compile --install-headers 'c:\users\maple\pycharmprojects\demvalidation\venv\include\site\python3.7\richdem' Check the logs for full command output. `

Have you any ideas to help me and fix the problem?

tylaa commented 3 years ago

I could fix the problem as deinstall all microsoft c++ buildup tools and reinstall only the newst one

TheMalekCH commented 2 years ago

Heya, I faced the same problem with the "cl.exe exit code 2" and tried out the above recommendations without success. Then I tried out something additionally which did work.

First I did the following recommendations with no effect:

Then additionally, I installed MSVC build tools separately and in its settings, I was able to configure the "Desktop development with C++" settings (I'm not sure if its the right name, as I translated it from my german pc). and in these settings I activated optional features (See attached picture). After that I ran again the x64 native tools command prompt and then the RichDEM installation worked in Python3.8 without problem with "pip install richdem".

Pic_RichDEM_MSVC_problem

As I am not a developer I have no clue what or why made the difference, but I thought I share my experience so others with the same problem could try this out.

dbaldig commented 2 years ago

Thanks TheMalekCH ! Looks like newer Python version are problematic, since it only works with Python 3.8

carlosedubarreto commented 1 year ago

I was able to install on windows using conda install richdem -c conda-forge