SuperElastix / SimpleElastix

Multi-lingual medical image registration library
http://simpleelastix.github.io
Apache License 2.0
513 stars 149 forks source link

setup.py.in installation failure, Windows 10, VS 2019, CMAKE 3.17.2 #372

Open olalla1999 opened 4 years ago

olalla1999 commented 4 years ago

Hello! I tried to configure SimpleElastix on windows 10, 64 Bits, VS 2019, cmake 3.17.2, python is Anaconda. While configuring in CMAKE some warnings appeared, then I "unclicked" some of the options leaving WRAP_PYTHON, BUILD_EXAMPLES and BUILD_TESTING activated. Then I pressed "Advanced" and I configurated again. Then I pressed "Generate".

After that, I went to the "Build" folder created and doble clicked on "SuperBuildSimpleITK.sln". Inside VS2019 I went to Build>Configuration Manager and activated the SimpleITK-build option (leaving the default activated options the same). Then, I built ALL_BUILD and waited for 45-50'. This were the last lines of the Command Window:

_10>-- Could NOT find Tclsh (missing: TCL_TCLSH) 10>-- Processing json files... 10>-- Processing json files...done 10>-- Found SWIG: C:/KK/Build/swigwin/swig.exe (found suitable version "3.0.12", minimum required is "3") 10>ERRORUnable to determing PythonVirtualEnv version! 10> 10>-- Found PythonVirtualEnv: C:/KK/Build/virtualenv/virtualenv.py (found version "") 10>CMake Error at Wrapping/Python/LegacyPackaging.cmake:60 (message): 10> In sufficient version of virutalenv for building wheels. Require 10> virtualenv>=13.0. 10>Call Stack (most recent call first): 10> Wrapping/Python/CMakeLists.txt:94 (include) 10> 10> 10>-- Adding Google Test source directory as subdirectory. 10>-- Looking for pthread.h 10>-- Looking for pthread.h - not found 10>-- Found Threads: TRUE 10>-- Generating tests... 10>-- Generating tests...Done 10>-- Configuring incomplete, errors occurred! 10>See also "C:/KK/Build/SimpleITK-build/CMakeFiles/CMakeOutput.log". 10>See also "C:/KK/Build/SimpleITK-build/CMakeFiles/CMakeError.log". 10>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(231,5): error MSB6006: "cmd.exe" exited with code 1. 10>Done building project "SimpleITK.vcxproj" -- FAILED. 11>------ Build started: Project: SimpleITKExamples, Configuration: Release x64 ------ 11>Creating directories for 'SimpleITKExamples' 11>Building Custom Rule C:/KK/SimpleElastix-master/SuperBuild/CMakeLists.txt 11>No download step for 'SimpleITKExamples' 11>No update step for 'SimpleITKExamples' 11>No patch step for 'SimpleITKExamples' 11>Performing configure step for 'SimpleITKExamples' 11>Not searching for unused variables given on the command line. 11>loading initial cache file C:/KK/Build/SimpleITKExamples-build/CMakeCacheInit.txt 11>-- The C compiler identification is MSVC 19.25.28614.0 11>-- The CXX compiler identification is MSVC 19.25.28614.0 11>-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe 11>-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - works 11>-- Detecting C compiler ABI info 11>-- Detecting C compiler ABI info - done 11>-- Detecting C compile features 11>-- Detecting C compile features - done 11>-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe 11>-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe - works 11>-- Detecting CXX compiler ABI info 11>-- Detecting CXX compiler ABI info - done 11>-- Detecting CXX compile features 11>-- Detecting CXX compile features - done 11>CMake Error at C:/KK/Build/SimpleITK-build/SimpleITKConfig.cmake:85 (include): 11> include could not find load file: 11> 11> C:/KK/Build/SimpleITK-build/SimpleITKTargets.cmake 11>Call Stack (most recent call first): 11> CMakeLists.txt:14 (find_package) 11> 11> 11>-- Configuring incomplete, errors occurred! 11>See also "C:/KK/Build/SimpleITKExamples-build/CMakeFiles/CMakeOutput.log". 11>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(231,5): error MSB6006: "cmd.exe" exited with code 1. 11>Done building project "SimpleITKExamples.vcxproj" -- FAILED. 12>------ Build started: Project: ALLBUILD, Configuration: Release x64 ------ 12>Building Custom Rule C:/KK/SimpleElastix-master/SuperBuild/CMakeLists.txt ========== Build: 10 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========

I didn't know what those errors meant but as I saw this folder was created inside "Build" folder, I thought it was all right.

imagen

C:\KK\Build\SimpleITK-build\Wrapping\Python\Packaging Inside here the IN file setup.py.in.

In order to install this file in Windows, I typed "python setup.py install" in the Command Prompt of Windows. To check if it worked, I went to Spyder app and wrote:

imagen

import SimpleITK as itk itk.E...

but no Elastix attribute was found for the SimpleITK library.

Can anyone help me?

Thanks in advance!

kaspermarstal commented 4 years ago

Can you build the "dist" target? This will build a wheel for you which may be easier to install.

It's hard to see what goes wrong from the command line (but thanks for the detailed description). You can try out the "azure-simpleitk-ci" branch which worked for me with VS 2019 just yesterday.

olalla1999 commented 4 years ago

Thank you for answering! but I finally solved it by reinstalling Anaconda3 and activating the option of "Add it to your PATH" (although the it's not recommended by Anaconda installer) that appears while you are installing it. Also I installed Git from https://git-scm.com/download/win .

Also, to configure and generate all the files, I used the Anaconda Prompt instead of the Windows prompt. [Important to activate WRAP_PYTHON and check that the paths of PYTHON_EXECUTABLE, PYTHON_INCLUDE_DIR and PYTHON_LIBRARY are related to anaconda's directory].

imagen

imagen

imagen

Then, I opened VS 2019 --> opened the Developer Command Prompt, went to the build folder directory and compiled everything from there: msbuild ALL_BUILD.vcxproj /p:Configuration=Release. Two and a half hours later (10 warnings 0 errors), I copied the file _SimpleITK.pyd that was created in the folder C:\KK\build\SimpleITK-build\Wrapping\Python and pasted it into the folder C:\KK\build\SimpleITK-build\Wrapping\Python\Packaging. This folder should look like this: imagen

Finally, I opened VS Code from Anaconda and typed python setup.py install. That was it!

I hope this helped Windows users!

PS: watch out the 'System enviornment variables' of Windows to have all the paths including cmake, visual studio, anaconda and Git.

kaspermarstal commented 4 years ago

Great job! And thanks for documenting your experience for future users. I will update the documentation.

lucasdevries commented 3 years ago

This last part of olalla1999's comment seems to work. I managed to finally build and install as well... Please be sure to uninstall older versions of SimpleITK (installed through pip for example) before installation. I used the command line method and then moved the files as mentioned above and ran the installation in the proper env. I spend a few days getting this to work, over the past three months.

My takeaways: 1) cmake, anaconda and Git should be in the environment PATH variable (be sure to check this in native windows 'cmd' application by typing PATH). 2) follow the instruction at https://simpleelastix.readthedocs.io/GettingStarted.html#using-the-command-line for windows. 3) after running cmake ../SimpleElastix/SuperBuild, turn all Wrapper Booleans to OFF (in the file: build/CMakeCache), except for Python wrapper, and then run msbuild /p:configuration=release ALL_BUILD.vcxproj 4) move the files as described above, open your env and run python setup.py install. 5) Check once again if you have multiple versions of SimpleITK, if you do, please delete the one (in my case it vas v2.0.2 that was already installed through pip). The current installation through the method above yields v2.0.0)