Install SimpleElastix on Windows for Python

空扰寡人 提交于 2021-02-08 10:43:03

问题


It seems some people have reported this on GitHub but I still couldn't find a clear solution to it - in the last step of installing the python module on Windows, there is no such folder called "/Wrapping/Python/Packaging" under "SimpleITK-build", and no file called "setup.py" in it. People have pointed out that it may be an issue coming from the improper Python Path. I tried adding Python Path under Anaconda to the system so that it can be accessed through cmd, but it didn't solve the problem. Then I uninstalled Anaconda, re-installed a separate Python and added Python Path to the system, and it didn't solve the problem, either. Could someone share some experience on how to solve this? I would appreciate your help.

Linghua

Below is the CMakeCacheInit file:


set( PYTHON_VIRTUALENV_SCRIPT "D:/SimpleElastix/virtualenv/virtualenv.py" CACHE "STRING" "" FORCE )
set( SimpleITK_4D_IMAGES "ON" CACHE "BOOL" "Add Image and I/O support for four spatial dimensions." FORCE )
  mark_as_advanced( SimpleITK_4D_IMAGES )
set( SimpleITK_GIT_PROTOCOL "https" CACHE "STRING" "If behind a firewall turn set this to 'https' or 'http'." FORCE )
  mark_as_advanced( SimpleITK_GIT_PROTOCOL )
  set_property(CACHE SimpleITK_GIT_PROTOCOL PROPERTY STRINGS "https;http;git")
set( SimpleITK_LUA_EXECUTABLE "D:/SimpleElastix/Lua/bin/lua" CACHE "STRING" "" FORCE )
set( SimpleITK_OPENMP "OFF" CACHE "BOOL" "If available, use OpenMP to speed up certain elastix computations." FORCE )
  mark_as_advanced( SimpleITK_OPENMP )
set( ExternalData_OBJECT_STORES "D:/SimpleElastix/ExternalData/Objects;/../.ExternalData" CACHE "STRING" "Semicolon-separated list of local directories holding data objects in the layout %(algo)/%(hash)." FORCE )
  mark_as_advanced( ExternalData_OBJECT_STORES )
set( CMAKE_BUILD_TYPE "Release" CACHE "STRING" "" FORCE )
set( CMAKE_MAKE_PROGRAM "C:/Program Files \(x86\)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe" CACHE "STRING" "" FORCE )
set( CMAKE_C_COMPILER "C:/Program Files \(x86\)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe" CACHE "STRING" "" FORCE )
set( CMAKE_C_FLAGS "/DWIN32 /D_WINDOWS /W3" CACHE "STRING" "Flags used by the C compiler during all build types." FORCE )
  mark_as_advanced( CMAKE_C_FLAGS )
set( CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1" CACHE "STRING" "Flags used by the C compiler during DEBUG builds." FORCE )
  mark_as_advanced( CMAKE_C_FLAGS_DEBUG )
set( CMAKE_C_FLAGS_MINSIZEREL "/MD /O1 /Ob1 /DNDEBUG" CACHE "STRING" "Flags used by the C compiler during MINSIZEREL builds." FORCE )
  mark_as_advanced( CMAKE_C_FLAGS_MINSIZEREL )
set( CMAKE_C_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG" CACHE "STRING" "Flags used by the C compiler during RELEASE builds." FORCE )
  mark_as_advanced( CMAKE_C_FLAGS_RELEASE )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "/MD /Zi /O2 /Ob1 /DNDEBUG" CACHE "STRING" "Flags used by the C compiler during RELWITHDEBINFO builds." FORCE )
  mark_as_advanced( CMAKE_C_FLAGS_RELWITHDEBINFO )
set( CMAKE_CXX_COMPILER "C:/Program Files \(x86\)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe" CACHE "STRING" "" FORCE )
set( CMAKE_CXX_FLAGS "/DWIN32 /D_WINDOWS /W3 /GR /EHsc" CACHE "STRING" "Flags used by the CXX compiler during all build types." FORCE )
  mark_as_advanced( CMAKE_CXX_FLAGS )
set( CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1" CACHE "STRING" "Flags used by the CXX compiler during DEBUG builds." FORCE )
  mark_as_advanced( CMAKE_CXX_FLAGS_DEBUG )
set( CMAKE_CXX_FLAGS_MINSIZEREL "/MD /O1 /Ob1 /DNDEBUG" CACHE "STRING" "Flags used by the CXX compiler during MINSIZEREL builds." FORCE )
  mark_as_advanced( CMAKE_CXX_FLAGS_MINSIZEREL )
set( CMAKE_CXX_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG" CACHE "STRING" "Flags used by the CXX compiler during RELEASE builds." FORCE )
  mark_as_advanced( CMAKE_CXX_FLAGS_RELEASE )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /O2 /Ob1 /DNDEBUG" CACHE "STRING" "Flags used by the CXX compiler during RELWITHDEBINFO builds." FORCE )
  mark_as_advanced( CMAKE_CXX_FLAGS_RELWITHDEBINFO )
set( CMAKE_LINKER "C:/Program Files \(x86\)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/link.exe" CACHE "FILEPATH" "Path to a program." FORCE )
  mark_as_advanced( CMAKE_LINKER )
set( CMAKE_EXE_LINKER_FLAGS "/machine:x64" CACHE "STRING" "Flags used by the linker during all build types." FORCE )
  mark_as_advanced( CMAKE_EXE_LINKER_FLAGS )
set( CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during DEBUG builds." FORCE )
  mark_as_advanced( CMAKE_EXE_LINKER_FLAGS_DEBUG )
set( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during MINSIZEREL builds." FORCE )
  mark_as_advanced( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during RELEASE builds." FORCE )
  mark_as_advanced( CMAKE_EXE_LINKER_FLAGS_RELEASE )
set( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/debug /INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during RELWITHDEBINFO builds." FORCE )
  mark_as_advanced( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO )
set( CMAKE_MODULE_LINKER_FLAGS "/machine:x64" CACHE "STRING" "Flags used by the linker during the creation of modules during all build types." FORCE )
  mark_as_advanced( CMAKE_MODULE_LINKER_FLAGS )
set( CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during the creation of modules during DEBUG builds." FORCE )
  mark_as_advanced( CMAKE_MODULE_LINKER_FLAGS_DEBUG )
set( CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "/INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during the creation of modules during MINSIZEREL builds." FORCE )
  mark_as_advanced( CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL )
set( CMAKE_MODULE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during the creation of modules during RELEASE builds." FORCE )
  mark_as_advanced( CMAKE_MODULE_LINKER_FLAGS_RELEASE )
set( CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "/debug /INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during the creation of modules during RELWITHDEBINFO builds." FORCE )
  mark_as_advanced( CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO )
set( CMAKE_SHARED_LINKER_FLAGS "/machine:x64" CACHE "STRING" "Flags used by the linker during the creation of shared libraries during all build types." FORCE )
  mark_as_advanced( CMAKE_SHARED_LINKER_FLAGS )
set( CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during the creation of shared libraries during DEBUG builds." FORCE )
  mark_as_advanced( CMAKE_SHARED_LINKER_FLAGS_DEBUG )
set( CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "/INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during the creation of shared libraries during MINSIZEREL builds." FORCE )
  mark_as_advanced( CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL )
set( CMAKE_SHARED_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during the creation of shared libraries during RELEASE builds." FORCE )
  mark_as_advanced( CMAKE_SHARED_LINKER_FLAGS_RELEASE )
set( CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "/debug /INCREMENTAL:NO" CACHE "STRING" "Flags used by the linker during the creation of shared libraries during RELWITHDEBINFO builds." FORCE )
  mark_as_advanced( CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO )
set( CMAKE_DL_LIBS "" CACHE "STRING" "" FORCE )
set( CMAKE_SYSTEM_PREFIX_PATH "C:/Program Files;C:/Program Files \(x86\);C:/Program Files/CMake;D:/SimpleElastix" CACHE "STRING" "" FORCE )
set( CMAKE_SYSTEM_LIBRARY_PATH "D:/SimpleElastix/bin;C:/Program Files/CMake/bin;/bin" CACHE "STRING" "" FORCE )
set( CMAKE_GENERATOR "Visual Studio 16 2019" CACHE "INTERNAL" "Name of generator." FORCE )
set( CMAKE_EXTRA_GENERATOR "" CACHE "INTERNAL" "Name of external makefile project generator." FORCE )
set( SITE "NoSiteGiven" CACHE "STRING" "" FORCE )
set( BUILDNAME "NoBuldNameGiven" CACHE "STRING" "" FORCE )

set( PYTHON_DEBUG_LIBRARY "PYTHON_DEBUG_LIBRARY-NOTFOUND" CACHE "FILEPATH" "Path to a library." FORCE )
  mark_as_advanced( PYTHON_DEBUG_LIBRARY )
set( PYTHON_EXECUTABLE "C:/Users/Linghua Zhang/AppData/Local/Programs/Python/Python37/python.exe" CACHE "FILEPATH" "Path to a program." FORCE )
  mark_as_advanced( PYTHON_EXECUTABLE )
set( PYTHON_LIBRARY "C:/Users/Linghua Zhang/AppData/Local/Programs/Python/Python37/libs/python37.lib" CACHE "FILEPATH" "Path to a library." FORCE )
  mark_as_advanced( PYTHON_LIBRARY )
set( PYTHON_INCLUDE_DIR "C:/Users/Linghua Zhang/AppData/Local/Programs/Python/Python37/include" CACHE "PATH" "Path to a file." FORCE )
  mark_as_advanced( PYTHON_INCLUDE_DIR )


回答1:


I solved this by doing the following:

  1. Re-install Anaconda3, add to PATH while installing (although it's not recommended by the installer). Make sure Python can be accessed by the system by checking in cmd. Just type "python" and see if its version pops out.
  2. Make sure your folder name does not contain any space (" ") as I do, especially for Windows users; If it does have space, choose another folder without any space in its name.
  3. Run CMake and "generate" python files. The build takes over 1 hr, and should end up with a notification of success.
  4. Copy _SimpleITK.pyd from the ...\Python\ directory to ...\Python\Packaging, as mentioned by "thatguy14"in https://github.com/SuperElastix/SimpleElastix/issues/233
  5. Open Anaconda Navigator, then open x64 native tools command prompt for VS, and install the python module following instructions in https://simpleelastix.readthedocs.io/GettingStarted.html

Hope it is helpful to others who meet the same problem!



来源:https://stackoverflow.com/questions/60766752/install-simpleelastix-on-windows-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!