Skip to content

Development with Visual Studio Tools 2022 not possible? #59576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Dr-Irv opened this issue Aug 21, 2024 · 7 comments
Open

Development with Visual Studio Tools 2022 not possible? #59576

Dr-Irv opened this issue Aug 21, 2024 · 7 comments
Labels

Comments

@Dr-Irv
Copy link
Contributor

Dr-Irv commented Aug 21, 2024

I have a new laptop, and followed the instructions to set up a Windows development environment using Visual Studio Build Tools 2022.

The conda environment that gets created puts a file in the conda environment: \envs\pandas-dev\etc\conda\activate.d\ called vs2019_compiler_vars.bat but that script doesn't recognize that VS BT 2022 is installed.

I'm not sure where that file comes from - I'm guessing its the c-compiler or cxx-compiler package in the environment?

The docs were updated by @natmokval in #50144 but I'm wondering if this was ever tested.

@Dr-Irv
Copy link
Contributor Author

Dr-Irv commented Aug 21, 2024

Here's what I have discovered is a workaround:

  • conda install vs2022_win-64 -c conda-forge
  • Go into wherever environments are and look in directory \envs\pandas-dev\etc\conda\activate.d
  • There will be files vs*_compiler_vars.bat. Remove all of them, except keep vs2022_compiler_vars.bat
  • Edit vs2022_compiler_vars.bat and change this line:
CALL "VC\Auxiliary\Build\vcvars%VCVARSBAT%.bat" -vcvars_ver=14.40 %WindowsSDKVer%

TO

CALL "VC\Auxiliary\Build\vcvars%VCVARSBAT%.bat" -vcvars_ver=14.41 %WindowsSDKVer%

Hopefully they will fix this in c-compiler to load the right version as well as fix the script to refer to 14.41 instead of 14.40

@AnujChitari
Copy link

vs2019_compiler_vars.bat File:

The vs2019_compiler_vars.bat file is typically used to set up environment variables and paths needed for Visual Studio 2019's compiler tools. This script is usually placed in the activate.d directory of your Conda environment to ensure that these settings are automatically applied when you activate the environment.
Since you are using Visual Studio Build Tools 2022, this file may not automatically work with VS2022. It is specifically tailored for VS2019.
Updating for VS2022:

To adapt the Conda environment to work with Visual Studio Build Tools 2022, you'll need to update or create a new script to set up the environment variables for VS2022. Visual Studio 2022 has different paths and environment settings compared to VS2019.

Steps to Resolve
Locate VS2022 Paths:

Find the paths and environment variables required for Visual Studio Build Tools 2022. These can typically be found in the installation directories or from the VS2022 command line tools. You can start the "Developer Command Prompt for Visual Studio 2022" and use the set command to see the environment variables.
Create or Update the Activation Script:

Create a new .bat file in the activate.d directory of your Conda environment to configure the environment for VS2022. You might name it vs2022_compiler_vars.bat. You will need to include the paths and environment variables specific to VS2022.

Here's a basic example of what this script might look like:
@echo off
set "VS2022_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
set "VC_VARS=%VS2022_DIR%\VC\Auxiliary\Build\vcvarsall.bat"
call "%VC_VARS% x64"

This script sets the VS2022_DIR to the installation path of VS2022 Build Tools and calls the vcvarsall.bat script to configure the environment for 64-bit compilation. Adjust the path according to your installation.

Test the Environment:

After creating or updating the script, activate your Conda environment and verify that the environment is properly configured for Visual Studio Build Tools 2022. You can test by compiling a small C/C++ project to ensure that everything is set up correctly.

I hope this helps you!

@Dr-Irv
Copy link
Contributor Author

Dr-Irv commented Aug 26, 2024

@simonjayhawkins
Copy link
Member

@Dr-Irv did #60170 also close this?

@Dr-Irv
Copy link
Contributor Author

Dr-Irv commented Apr 16, 2025

@Dr-Irv did #60170 also close this?

Partially - but I think we should keep the issue open until VS 2022 works right, which depends on conda-forge/compilers-feedstock#66 getting addressed

@simonjayhawkins
Copy link
Member

no problem. thanks for the update.

incidentally have you tried WSL? I have a windows laptop but have not used any dev tools on Windows itself (except VS Code) for years. The only problem I've had, which has probably been sorted by now, is cuda support. I use another machine for that with ubuntu server installed and use the ssh plugin for VS Code instead. So seamless that it's easy to forget whether i'm using WSL or SSH.

@Dr-Irv
Copy link
Contributor Author

Dr-Irv commented Apr 16, 2025

incidentally have you tried WSL? I have a windows laptop but have not used any dev tools on Windows itself (except VS Code) for years. The only problem I've had, which has probably been sorted by now, is cuda support. I use another machine for that with ubuntu server installed and use the ssh plugin for VS Code instead. So seamless that it's easy to forget whether i'm using WSL or SSH.

Yes, I do use WSL, but not for software development, because I have third party tools that I use that don't work right under WSL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants