Anaconda Prompt base環境におけるvswhere関連エラー修正

最近Pyfolioをインストールしたあとに(結局アンインストールしたが)以下のようなエラーが出たため、それへの対処をメモしておきたいと思う。

エラー内容

Anaconda Promptを起動したときに下記のようなエラーが表示されるようになった。

C:\Users\user\PythonDoc>SET DISTUTILS_USE_SDK=1

C:\Users\user\PythonDoc>SET MSSdk=1

C:\Users\user\PythonDoc>SET "VS_VERSION=15.0"

C:\Users\user\PythonDoc>SET "VS_MAJOR=15"

C:\Users\user\PythonDoc>SET "VS_YEAR=2017"

C:\Users\user\PythonDoc>set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"

C:\Users\user\PythonDoc>set "MSYS2_ENV_CONV_EXCL=CL"

C:\Users\user\PythonDoc>set "PY_VCRUNTIME_REDIST=\bin\vcruntime140.dll"

C:\Users\user\PythonDoc>set "CXX=cl.exe"

C:\Users\user\PythonDoc>set "CC=cl.exe"

C:\Users\user\PythonDoc>set "VSINSTALLDIR="

C:\Users\user\PythonDoc>set "NEWER_VS_WITH_OLDER_VC=0"

C:\Users\user\PythonDoc>for /F "usebackq tokens=*" %i in (`vswhere.exe -nologo -products * -version [15.0,16.0) -property installationPath`) do (set "VSINSTALLDIR=%i\" )

C:\Users\user\PythonDoc>if not exist "" (for /F "usebackq tokens=*" %i in (`vswhere.exe -nologo -products * -requires Microsoft.VisualStudio.Component.VC.v141.x86.x64 -property installationPath`) do (
set "VSINSTALLDIR=%i\"
 set "NEWER_VS_WITH_OLDER_VC=1"
) )

C:\Users\user\PythonDoc>if not exist "" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" )

C:\Users\user\PythonDoc>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" )

C:\Users\user\PythonDoc>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\" )

C:\Users\user\PythonDoc>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\" )

C:\Users\user\PythonDoc>IF NOT "" == "" (
set "INCLUDE=;"
 set "LIB=;"
 set "CMAKE_PREFIX_PATH=;"
)

C:\Users\user\PythonDoc>call :GetWin10SdkDir

C:\Users\user\PythonDoc>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\user\PythonDoc>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\user\PythonDoc>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1

C:\Users\user\PythonDoc>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1

C:\Users\user\PythonDoc>if errorlevel 1 exit /B 1

C:\Users\user\PythonDoc>exit /B 0

C:\Users\user\PythonDoc>for /F %i in ('dir /ON /B "\include\10.*"') DO (SET WindowsSDKVer=%~i )
指定されたファイルが見つかりません。

C:\Users\user\PythonDoc>if errorlevel 1 (echo "Didn't find any windows 10 SDK. I'm not sure if things will work, but let's try..." )  else (echo Windows SDK version found as: "" )
Windows SDK version found as: ""

C:\Users\user\PythonDoc>IF "win-64" == "win-64" (
set "BITS=64"
 set "CMAKE_PLAT=x64"
)  ELSE (
set "BITS=32"
 set "CMAKE_PLAT=Win32"
)

C:\Users\user\PythonDoc>IF 2017 GEQ 2019 (
set "CMAKE_GEN=Visual Studio 15 2017"
 set "USE_NEW_CMAKE_GEN_SYNTAX=1"
)  ELSE (
IF "win-64" == "win-64" (set "CMAKE_GEN=Visual Studio 15 2017 Win64" )  else (set "CMAKE_GEN=Visual Studio 15 2017" )
 set "USE_NEW_CMAKE_GEN_SYNTAX=0"
)

C:\Users\user\PythonDoc>echo "NEWER_VS_WITH_OLDER_VC=0"
"NEWER_VS_WITH_OLDER_VC=0"

C:\Users\user\PythonDoc>IF "0" == "1" (
set "CMAKE_GEN=Visual Studio 16 2019"
 set "USE_NEW_CMAKE_GEN_SYNTAX=1"
)

C:\Users\user\PythonDoc>IF "" == "" SET "CMAKE_GENERATOR=Visual Studio 15 2017 Win64"

C:\Users\user\PythonDoc>IF "0" == "1" (
IF "" == "" SET "CMAKE_GENERATOR_PLATFORM=x64"
 IF "" == "" SET "CMAKE_GENERATOR_TOOLSET=v141"
)

C:\Users\user\PythonDoc>pushd C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\
指定されたパスが見つかりません。

C:\Users\user\PythonDoc>CALL "VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.16
指定されたパスが見つかりません。

C:\Users\user\PythonDoc>popd

C:\Users\user\PythonDoc>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\user\PythonDoc>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\user\PythonDoc>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1

C:\Users\user\PythonDoc>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1

C:\Users\user\PythonDoc>if errorlevel 1 exit /B 1

C:\Users\user\PythonDoc>exit /B 0

(base) C:\Users\user\PythonDoc>

エラー表示を消す方法

色々試行錯誤したが、結果としては、

C:\Users\user\Anaconda3\etc\conda\activate.d
の配下にある、vs2017_compiler_vars.bat を削除したところ、上記エラー表示がされなくなった。

実際のところこれが適切な方法なのかは自分自身わかっていないが、今のところは問題は出ていない。