Установите SimpleElastix в Windows для Python
Кажется, некоторые люди сообщили об этом на GitHub, но я все еще не мог найти четкого решения для этого - на последнем этапе установки модуля python в Windows нет такой папки с именем "/Wrapping/Python/Packaging" под "SimpleITK-build", и в нем нет файла с именем"setup.py". Люди указали, что это может быть проблема из-за неправильного пути Python. Я попытался добавить Python Path в Anaconda в систему, чтобы к нему можно было получить доступ через cmd, но это не решило проблему. Затем я удалил Anaconda, переустановил отдельный Python и добавил Python Path в систему, и это тоже не решило проблему. Может ли кто-нибудь поделиться опытом, как это решить? Буду признателен за вашу помощь.
Линхуа
Ниже представлен файл CMakeCacheInit:
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 ответ
Я решил это, выполнив следующие действия:
- Переустановите Anaconda3, добавьте в PATH во время установки (хотя это не рекомендуется установщиком). Убедитесь, что система имеет доступ к Python, проверив cmd. Просто введите "python" и посмотрите, появится ли его версия.
- Убедитесь, что имя вашей папки не содержит пробелов (" "), как это делаю я, особенно для пользователей Windows; Если в ней есть место, выберите другую папку без пробела в ее имени.
- Запустите CMake и "сгенерируйте" файлы Python. Сборка занимает более 1 часа и должна завершиться уведомлением об успехе.
- Скопируйте _SimpleITK.pyd из каталога...\Python\ в...\Python\Packaging, как указано "thatguy14" в https://github.com/SuperElastix/SimpleElastix/issues/233.
- Откройте Anaconda Navigator, затем откройте командную строку собственных инструментов x64 для VS и установите модуль python, следуя инструкциям в https://simpleelastix.readthedocs.io/GettingStarted.html.
Надеюсь, это поможет другим, столкнувшимся с той же проблемой!