pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.92k stars 18.03k forks source link

Development with Visual Studio Tools 2022 not possible? #59576

Open Dr-Irv opened 3 months ago

Dr-Irv commented 3 months ago

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 commented 3 months ago

Here's what I have discovered is a workaround:

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 commented 3 months ago

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 "%VCVARS% 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 commented 3 months ago

See https://github.com/conda-forge/compilers-feedstock/issues/66