# Executing Python command with CMake under CygWin fails with Errno 2

**URL:** https://discourse.cmake.org/t/executing-python-command-with-cmake-under-cygwin-fails-with-errno-2/15290
**Category:** Usage
**Created:** [November 6, 2025, 9:12pm UTC](https://discourse.cmake.org/t/executing-python-command-with-cmake-under-cygwin-fails-with-errno-2/15290 "2025-11-06T21:12:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tbeu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tbeu/32/5887_2.png) [@tbeu](https://discourse.cmake.org/u/tbeu)
#### Post date: [November 6, 2025, 9:12pm UTC](https://discourse.cmake.org/t/executing-python-command-with-cmake-under-cygwin-fails-with-errno-2/15290/1 "2025-11-06T21:12:48Z")

</div>

I have the following lines in my CMake file, basically running a python script.

```auto
find_package(Python3 COMPONENTS Interpreter)
if(Python3_Interpreter_FOUND)
	set(MY_CTESTS_DIR ${PROJECT_BINARY_DIR}/tests)
	set(MY_TESTING_DIR ${MY_CTESTS_DIR}/temporary)
	file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/test/my_script.py" NATIVE_SCRIPT_SCRIPT)
	file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/tests" NATIVE_CTESTS_DIR)
	file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/test" NATIVE_WORKING_DIR)
	execute_process(
		COMMAND "${Python3_EXECUTABLE}" "${NATIVE_SCRIPT_SCRIPT}" "${NATIVE_CTESTS_DIR}"
		WORKING_DIRECTORY "${NATIVE_WORKING_DIR}"
		RESULT_VARIABLE TEST_SCRIPT_RESULT
		OUTPUT_VARIABLE TEST_SCRIPT_OUTPUT
		ERROR_VARIABLE TEST_SCRIPT_ERROR
	)
	if(NOT TEST_SCRIPT_RESULT EQUAL 0)
		message(FATAL_ERROR "Python script failed: ${TEST_SCRIPT_ERROR}")
	endif()
endif()

```

This works on every platform I test, except CygWin (with CMake 3.31.3). The error reported is that the python script file is not found (though it is available).

```auto
-- Found Python3: /cygdrive/c/hostedtoolcache/windows/Python/3.9.13/x64/python3.exe (found version "3.9.13") found components: Interpreter
CMake Error at cmake/test.cmake:36 (message):
  Python script failed:
  C:\hostedtoolcache\windows\Python\3.9.13\x64\python3.exe: can't open file
  'D:\cygdrive\d\a\my\my\test\my_script.py': [Errno 2] No
  such file or directory
Call Stack (most recent call first):
  CMakeLists.txt:35 (include)
-- Configuring incomplete, errors occurred!
Error: Process completed with exit code 1.Note, that I already tried to circumvent the CygWin path issue, but with no success. What is the correct way to run Python scripts via CMake on CygWin (for GitHub Actions)? Thank you!

```

Note, that I already tried to circumvent the CygWin path issue, but with no success. What is the correct way to run Python scripts via CMake on CygWin (for GitHub Actions)? Thank you!

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [November 7, 2025, 10:20am UTC](https://discourse.cmake.org/t/executing-python-command-with-cmake-under-cygwin-fails-with-errno-2/15290/2 "2025-11-07T10:20:57Z")

</div>

You’re using a normal Windows Python which does not understand cygwin paths.

If you’re using cygwin, all tools shall be installed by cygwin.
