diff -urN a/Modules/getpath.c b/Modules/getpath.c --- a/Modules/getpath.c.orig 2014-02-20 17:14:33.371768500 +0000 +++ b/Modules/getpath.c 2014-02-20 17:31:20.382142600 +0000 @@ -879,6 +879,30 @@ else wcsncpy(exec_prefix, _exec_prefix, MAXPATHLEN); +#ifdef MS_WINDOWS + if (_path) { + /* Add path of executable/dll to system path. This + * is so that the correct tcl??.dll and tk??.dll get used. */ + path_buffer = _Py_char2wchar(_path, NULL); + wchar_t *module_path = dllpath[0] ? dllpath : progpath; + wchar_t *new_path = (wchar_t *)alloca(sizeof(wchar_t)*(wcslen(L"PATH=")+wcslen(module_path)+1+wcslen(path_buffer)+1)); + if (new_path) { + wcscpy( new_path, L"PATH=" ); + wcscat( new_path, module_path ); + wchar_t *slashes = wcschr( new_path, L'/' ); + while (slashes) { + *slashes = '\\'; + slashes = wcschr( slashes+1, L'/' ); + } + wchar_t *end = wcsrchr(new_path, L'\\') ? wcsrchr(new_path, L'\\') : new_path + wcslen(new_path); + end[0] = L';'; + end[1] = L'\0'; + wcscat( new_path, path_buffer ); + _wputenv( new_path ); + PyMem_Free(path_buffer); + } + } +#endif PyMem_Free(_pythonpath); PyMem_Free(_prefix); PyMem_Free(_exec_prefix);