每当我在“基本”环境中启动 Anaconda Prompt 时,有关 VSINSTALLDIR 和 vs2019 的长错误消息

Posted

技术标签:

【中文标题】每当我在“基本”环境中启动 Anaconda Prompt 时,有关 VSINSTALLDIR 和 vs2019 的长错误消息【英文标题】:Long error messages about VSINSTALLDIR and vs2019 whenever I start Anaconda Prompt in my "base" environment 【发布时间】:2021-10-17 04:34:29 【问题描述】:

每次我在 Windows 10 64 位系统上启动 Anaconda Prompt 终端时,都会收到很长的 Windows shell 脚本消息列表,其中包含一些关于“vs2019”的嵌入式错误。这似乎是在我将 IBM JupyterLab 软件包 Elyra Snippets 安装到我的 Anaconda 基础环境中时开始的。

如果我为 Windows 10“开始”菜单上可用的任何其他虚拟环境启动 Anaconda 提示,我不会收到这些消息。

以下是我收到的脚本控制台错误消息的完整列表。即使我只是搜索似乎主要的内容,谷歌搜索也无济于事:

"C:\Users\richadmin>CALL c:\ProgramData\Anaconda3\etc\conda\activate.d\vs2017_get_vsinstall_dir.bat
Did not find VSINSTALLDIR
Windows SDK version found as: "10.0.19041.0"
The system cannot find the path specified.
Did not find VSINSTALLDIR"

我确实安装了 VS2019 社区版,但它似乎正在寻找 VS2017。

在 Windows 控制台消息、vs2019 和 vs2017 消息以及其他嵌入式 shell 脚本之间,这是一个很大的漏洞,我已经多次尝试修复它并且每次都浪费时间。

############################################## ##############

这里是所有回显到控制台的 shell 消息。

>     C:\Users\richadmin>SET DISTUTILS_USE_SDK=1
>     
>     C:\Users\richadmin>SET MSSdk=1
>     
>     C:\Users\richadmin>SET "VS_VERSION=15.0"
>     
>     C:\Users\richadmin>SET "VS_MAJOR=15"
>     
>     C:\Users\richadmin>SET "VS_YEAR=2017"
>     
>     C:\Users\richadmin>set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"
>     
>     C:\Users\richadmin>set "MSYS2_ENV_CONV_EXCL=CL"
>     
>     C:\Users\richadmin>set "PY_VCRUNTIME_REDIST=\bin\vcruntime140.dll"
>     
>     C:\Users\richadmin>set "CXX=cl.exe"
>     
>     C:\Users\richadmin>set "CC=cl.exe"
>     
>     C:\Users\richadmin>CALL C:\ProgramData\Anaconda3\etc\conda\activate.d\vs2017_get_vsinstall_dir.bat
>     Did not find VSINSTALLDIR
>     Windows SDK version found as: "10.0.19041.0"
>     **********************************************************************
>     ** Visual Studio 2019 Developer Command Prompt v16.9.4
>     ** Copyright (c) 2021 Microsoft Corporation
>     **********************************************************************
>     [ERROR:vcvars.bat] Toolset directory for version '14.16' was not found.
>     [ERROR:VsDevCmd.bat] *** VsDevCmd.bat encountered errors. Environment may be incomplete and/or incorrect. ***
>     [ERROR:VsDevCmd.bat] In an uninitialized command prompt, please 'set VSCMD_DEBUG=[value]' and then re-run
>     [ERROR:VsDevCmd.bat] vsdevcmd.bat [args] for additional details.
>     [ERROR:VsDevCmd.bat] Where [value] is:
>     [ERROR:VsDevCmd.bat]    1 : basic debug logging
>     [ERROR:VsDevCmd.bat]    2 : detailed debug logging
>     [ERROR:VsDevCmd.bat]    3 : trace level logging. Redirection of output to a file when using this level is recommended.
>     [ERROR:VsDevCmd.bat] Example: set VSCMD_DEBUG=3
>     [ERROR:VsDevCmd.bat]          vsdevcmd.bat > vsdevcmd.trace.txt 2>&1
>     Did not find VSINSTALLDIR
>     
>     C:\Users\richadmin>SET DISTUTILS_USE_SDK=1
>     
>     C:\Users\richadmin>SET MSSdk=1
>     
>     C:\Users\richadmin>SET "VS_VERSION=16.0"
>     
>     C:\Users\richadmin>SET "VS_MAJOR=16"
>     
>     C:\Users\richadmin>SET "VS_YEAR=2019"
>     
>     C:\Users\richadmin>set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"
>     
>     C:\Users\richadmin>set "MSYS2_ENV_CONV_EXCL=CL"
>     
>     C:\Users\richadmin>set "PY_VCRUNTIME_REDIST=\bin\vcruntime140.dll"
>     
>     C:\Users\richadmin>set "CXX=cl.exe"
>     
>     C:\Users\richadmin>set "CC=cl.exe"
>     
>     C:\Users\richadmin>set "VSINSTALLDIR="
>     
>     C:\Users\richadmin>for /F "usebackq tokens=*" %i in (`vswhere.exe -nologo -products * -version [16.0,17.0) -property installationPath`) do (set "VSINSTALLDIR=%i\" )
>     
>     C:\Users\richadmin>(set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\" )
>     
>     C:\Users\richadmin>(set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\" )
>     
>     C:\Users\richadmin>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\" (for /F "usebackq tokens=*" %i in
> (`vswhere.exe -nologo -products * -requires
> Microsoft.VisualStudio.Component.VC.v142.x86.x64 -property
> installationPath`) do (set "VSINSTALLDIR=%i\" ) )
>     
>     C:\Users\richadmin>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\" (set "VSINSTALLDIR=C:\Program Files
> (x86)\Microsoft Visual Studio\2019\Professional\" )
>     
>     C:\Users\richadmin>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\" (set "VSINSTALLDIR=C:\Program Files
> (x86)\Microsoft Visual Studio\2019\Community\" )
>     
>     C:\Users\richadmin>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\" (set "VSINSTALLDIR=C:\Program Files
> (x86)\Microsoft Visual Studio\2019\BuildTools\" )
>     
>     C:\Users\richadmin>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\" (set "VSINSTALLDIR=C:\Program Files
> (x86)\Microsoft Visual Studio\2019\Enterprise\" )
>     
>     C:\Users\richadmin>IF NOT "" == "" (
>     set "INCLUDE=;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\um;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\winrt;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\cppwinrt;C:\Program Files (x86)\Windows
> Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\um;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\winrt;C:\Program Files (x86)\Windows
> Kits\10\include\10.0.19041.0\cppwinrt"
>      set "LIB=;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86;C:\Program Files (x86)\Windows
> Kits\10\lib\10.0.19041.0\ucrt\x86;C:\Program Files (x86)\Windows
> Kits\10\lib\10.0.19041.0\um\x86;C:\Program Files (x86)\Windows
> Kits\NETFXSDK\4.8\lib\um\x64;C:\Program Files (x86)\Windows
> Kits\10\lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows
> Kits\10\lib\10.0.19041.0\um\x64"
>      set "CMAKE_PREFIX_PATH=;"
>     )
>     
>     C:\Users\richadmin>call :GetWin10SdkDir
>     
>     C:\Users\richadmin>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1
>     
>     C:\Users\richadmin>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1
>     
>     C:\Users\richadmin>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1
>     
>     C:\Users\richadmin>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1
>     
>     C:\Users\richadmin>if errorlevel 1 exit /B 1
>     
>     C:\Users\richadmin>exit /B 0
>     
>     C:\Users\richadmin>for /F %i in ('dir /ON /B "C:\Program Files (x86)\Windows Kits\10\\include\10.*"') DO (SET WindowsSDKVer=%~i )
>     
>     C:\Users\richadmin>(SET WindowsSDKVer=10.0.10240.0 )
>     
>     C:\Users\richadmin>(SET WindowsSDKVer=10.0.18362.0 )
>     
>     C:\Users\richadmin>(SET WindowsSDKVer=10.0.19041.0 )
>     
>     C:\Users\richadmin>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: "10.0.19041.0" )
>     Windows SDK version found as: "10.0.19041.0"
>     
>     C:\Users\richadmin>IF 2019 GEQ 2019 (
>     set "CMAKE_GEN=Visual Studio 16 2019"
>      IF "win-64" == "win-64" (
>     set "BITS=64"
>      set "CMAKE_PLAT=x64"
>     )  ELSE (
>     set "BITS=32"
>      set "CMAKE_PLAT=Win32"
>     )
>     )  ELSE (IF "win-64" == "win-64" (
>     set "CMAKE_GEN=Visual Studio 16 2019 Win64"
>      set "BITS=64"
>     )  else (
>     set "CMAKE_GEN=Visual Studio 16 2019"
>      set "BITS=32"
>     ) )
>     
>     C:\Users\richadmin>pushd C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\
>     
>     C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>CALL "VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.29 10.0.19041.0
>     **********************************************************************
>     ** Visual Studio 2019 Developer Command Prompt v16.9.4
>     ** Copyright (c) 2021 Microsoft Corporation
>     **********************************************************************
>     [ERROR:vcvars.bat] Toolset directory for version '14.29' was not found.
>     [ERROR:VsDevCmd.bat] *** VsDevCmd.bat encountered errors. Environment may be incomplete and/or incorrect. ***
>     [ERROR:VsDevCmd.bat] In an uninitialized command prompt, please 'set VSCMD_DEBUG=[value]' and then re-run
>     [ERROR:VsDevCmd.bat] vsdevcmd.bat [args] for additional details.
>     [ERROR:VsDevCmd.bat] Where [value] is:
>     [ERROR:VsDevCmd.bat]    1 : basic debug logging
>     [ERROR:VsDevCmd.bat]    2 : detailed debug logging
>     [ERROR:VsDevCmd.bat]    3 : trace level logging. Redirection of output to a file when using this level is recommended.
>     [ERROR:VsDevCmd.bat] Example: set VSCMD_DEBUG=3
>     [ERROR:VsDevCmd.bat]          vsdevcmd.bat > vsdevcmd.trace.txt 2>&1
>     
>     (base) C:\Users\richadmin>

【问题讨论】:

如果您不使用 VS 2017,我不确定我是否理解您为什么专门 CALLing 一个名为 vs2017_get_vsinstall_dir.bat 的文件。我建议您不要运行文件打算确定VS2017安装目录的位置,如果你还没有安装的话。您可以清楚地看到您的目录位置正在稍后使用vswhere.exe 确定。 这是一个关于“Anaconda Console for Base”环境启动的问题。我不是calling 那个文件vs2017_get_vsinstall_dir.bat 我自己。当我为 JupyterLab 安装 IBM 的 Elyra 插件时,它以某种方式被引入到 Anaconda 命令提示符启动中。 Elyra 软件包没有卸载程序可以撤消在 Anaconda Base 命令控制台启动脚本中所做的更改。我不知道如何扭转这些变化。有谁知道 Anaconda 控制台启动时运行的是什么 .bat 文件?它位于哪里? 我已经解释过,您的设置正在调用名称中包含 2017 的文件,因此它正在尝试使用失败的方法确定 2017 版本的 VS 可执行文件的位置找到它。当该方法失败时,它会输出一条消息来表明这一点。之后,它使用另一种方法来搜索任何可执行文件,即vswhere.exe,它确实找到了它。如果您不想要该消息,并且您别无选择只能使用vs2017_get_vsinstall_dir.bat,那么合乎逻辑的方法是打开批处理文件并REMark 不需要的行。 【参考方案1】:

我也有类似的东西。我在 Anaconda 提示符中输入了conda uninstall vswhere。之后消息就消失了。

请仔细查看哪些软件包也会因此而被删除,尤其是在您确实需要 Visual Studio 时。我可以不用它,因此我能够忍受它。

'vswhere' 似乎是一个搜索 Visual Studio 所在位置的包。这就是为什么它似乎仍在搜索 Visual Studio 是否实际存在的原因。

【讨论】:

以上是关于每当我在“基本”环境中启动 Anaconda Prompt 时,有关 VSINSTALLDIR 和 vs2019 的长错误消息的主要内容,如果未能解决你的问题,请参考以下文章

Spyder 未从 Anaconda 环境之一启动

如何更改默认的Anaconda python环境

安装 keras 后启动时,anaconda 提示始终以这些命令集开头

ANACONDA实用命令

`anaconda`是否为每个新环境创建一个单独的PYTHONPATH变量?

每当我安装新的软件包/模块时,都会出现Anaconda conda.compat模块警告