Open Dr-Irv opened 3 months ago
It is absolutely possible to develop with Visual Studio 2022 Build Tools on Windows. The issue you're encountering with the init file not being installed is likely an isolated problem that can be resolved with the right steps.
1)Verify Build Tools Installation Make sure that Visual Studio 2022 Build Tools are properly installed:
Open the Visual Studio Installer. Ensure you have Visual Studio Build Tools 2022 installed. Under Workloads, make sure Desktop development with C++ is selected.
2)Install Required Components Sometimes, specific components might be missing: In the Visual Studio Installer, click Modify on the Build Tools installation. Ensure that MSVC v143 - VS 2022 C++ x64/x86 build tools and C++ CMake tools for Windows are selected.
3)Run the Build Tools Command Line To check if the command-line tools are working, open the Developer Command Prompt for Visual Studio or a regular Command Prompt with the appropriate environment setup:
Open Start Menu, search for Developer Command Prompt for Visual Studio 2022, and run it. Try running cl.exe to see if the compiler is recognized.
4)Environment Variables Ensure environment variables are set up correctly: Check that paths to cl.exe, link.exe, and other tools are in your PATH environment variable.
I hope this should work!
I hope this should work!
This solves the problem, but is not solving the fundamental problem, which is when you install c-compiler
from conda-forge
, it doesn't install the correct script in \envs\pandas-dev\etc\conda\activate.d\
that causes the conda environment to be properly updated upon activation with the right paths.
The issue is that c-compiler
is installing vs2019_win-64
rather than vs2022_win-64
I also have this problem.
Windows Server 2016 machine with Visual Studio 2022 installed and a fresh install of Anaconda 2024.06-1. When I conda env create
my environment, vs2019_win-64
gets installed. After that, conda activate
produces errors and does not find cl.exe
and friends.
After I conda install vs2022_win-64
and conda activate my_vs2022_env
, cl.exe
winds up on the path but the CMake default generator is set to Visual Studio 16 2019
. This causes CMake to fail because it can't find VS2019.
Removing envs/my_vs2022_env/etc/conda/activate.d/vs2019_compiler_vars.bat
and resetting my shell seems to have fixed the issue for now. How can we solve this properly?
I've just confirmed that removing vs2019_compiler_vars.bat
causes CMAKE_GENERATOR
and friends to be set correctly for Visual Studio 2022.
On reflection, I think the root cause here is the fact that conda install -c conda-forge compilers
does not (and at present cannot) actually do what it says on the box when running on Windows: that is, install the compiler used to build the ecosystem. Instead, we're in a situation where we can install some packages related to a particular version of Visual C++, but we have no way to install the compiler itself.
I don't have a clear answer for what the Right Thing would be here. The best idea I've got is to avoid installing compilers
so that I don't pick up the dependency on vs2019_win-64
. Then, when I run Visual Studio 2022, I'm still running some small risk of ABI incompatibility but at least I'm not tripping over the vs2019 batch files.
It sure would be convenient if Microsoft would provide a conda-forge package that actually installs VC++ but I'm going to guess that that isn't on their product roadmap.
For me even with the workarounds of removing the old vs2019_compiler_vars.bat
file, cl.exe
was not found after conda activate
in a normal powershell console. The conda install command prints at the end:
C:\Program Files\Microsoft Visual Studio\2022\Community>if "14.41-14.41" == "14.40-14.41" (CALL "VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.41 10.0.22621.0 ) else (CALL "VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.41 10.0.22621.0 )
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.11.5
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
So it seems to detect that I've VS 2022 installed.
Everything works, however, if you activate conda in the "Developer Command Prompt".
Is there a way to make it work in "normal" consoles?
My current workaround for this issue is to install vs2022_win-64
rather than compilers
, cxx-compiler
or c-compiler
. This does require me to have Windows-specific environment.yml
files, but I have to use those anyway at the moment.
Solution to issue cannot be found in the documentation.
Issue
Not sure if this issue goes here or somewhere else.
This is on Windows 11. First you install the latest Visual Studio 2022 Build Tools. No other Visual Studio is installed.
If you create a new environment, and do
conda install c-compiler -c conda-forge
, the batch file that is installed in\envs\pandas-dev\etc\conda\activate.d
isvs2019_compiler_vars.bat
which does not work with Microsoft Visual Studio 2022 Build Tools.Installing
c-compiler
causesvs2019_win-x64
to be installed. I would have expectedvs2022_win-x64
to be installed.If I first install
vs2022_win-x64
, thenc-compiler
, then remove\envs\pandas-dev\etc\conda\activate.d\vs2019_compiler_vars.bat
, then editvs2022_compiler_vars.bat
to use version 14.41, instead of 14.40, I think it will work properly.Trying to do this for building pandas on Windows.
Installed packages
Environment info