diff -Naur Python-3.7.0-orig/Modules/getpath.c Python-3.7.0/Modules/getpath.c --- Python-3.7.0-orig/Modules/getpath.c 2018-07-12 10:21:50.372404600 +0300 +++ Python-3.7.0/Modules/getpath.c 2018-07-12 10:21:50.700005100 +0300 @@ -1005,6 +1005,31 @@ memset(exec_prefix, 0, sizeof(exec_prefix)); calculate_exec_prefix(core_config, calculate, exec_prefix); +#ifdef MS_WINDOWS + if (calculate->path_env) { + wchar_t *module_path, *new_path; + // Add path of executable/dll to system path. This + // is so that the correct tcl??.dll and tk??.dll get used. + module_path = config->dll_path[0] ? config->dll_path : config->program_full_path; + new_path = (wchar_t *)alloca(sizeof(wchar_t)*(wcslen(L"PATH=") + wcslen(module_path) + 1 + wcslen(calculate->path_env) + 1)); + if (new_path) { + wchar_t *slashes, *end; + wcscpy(new_path, L"PATH="); + wcscat(new_path, module_path); + slashes = wcschr(new_path, L'/'); + while (slashes) { + *slashes = L'\\'; + slashes = wcschr(slashes+1, L'/'); + } + end = wcsrchr(new_path, L'\\') ? wcsrchr(new_path, L'\\') : new_path + wcslen(new_path); + end[0] = L';'; + end[1] = L'\0'; + wcscat(new_path, calculate->path_env); + _wputenv(new_path); + } + } +#endif + if ((!calculate->prefix_found || !calculate->exec_prefix_found) && !Py_FrozenFlag) {